📜  门| GATE-CS-2015(套装3)|第 65 题

📅  最后修改于: 2021-09-26 03:11:46             🧑  作者: Mango

考虑以下具有五个指令 I1 到 I5 的代码序列。这些指令中的每一个都具有以下格式。

OP Ri, Rj, Rk 

其中对寄存器 Rj 和 Rk 的内容执行操作 OP,并将结果存储在寄存器 Ri 中。

I1 : ADD R1, R2, R3
   I2 : MUL R7, R1, R3
   I3 : SUB R4, R1, R5
   I4 : ADD R3, R2, R4
   I5 : MUL R7, R8, R9 

考虑以下三个语句:

S1: There is an anti-dependence between instructions I2 and I5.
S2: There is an anti-dependence between instructions I2 and I4.
S3: Within an instruction pipeline an anti-dependence always 
    creates one or more stalls. 

以上哪一项是/是正确的?

(A)只有 S1 为真
(B)只有 S2 为真
(C)只有 S1 和 S2 为真
(D)只有 S2 和 S3 为真答案:(乙)
说明:给定的指令可以写成如下:

I1: R1 = R2 + R3
I2: R7 = R1 * R3
I3: R4 = R1 - R5 
I4: R3 = R2 + R4
I5: R7 = R8 * R9 

反依赖性,也称为读后写 (WAR),当指令需要稍后更新的值时会发生。

S1: There is an anti-dependence between instructions I2 and I5.
False, I2 and I5 don't form any write after read situation.  
They both write R7.

S2: There is an anti-dependence between instructions I2 and I4.
True, I2 reads R3 and I4 writes it.

S3: Within an instruction pipeline an anti-dependence always 
    creates one or more stalls. 
Anti-dependency can be removed by renaming variables. 
See following example.
1. B = 3
2. A = B + 1
3. B = 7
Renaming of variables could remove the dependency.
1. B = 3
N. B2 = B
2. A = B2 + 1
3. B = 7

这个问题的测验