l******y 发帖数: 204 | 1 Computer Architecture的一个问题
话说有这么一个Scalar MIPS code for DAXPY (aX + Y):
L.D F0,a ;load scalar a
DADDIU R4,Rx,#392 ;last address to load
Loop: L.D F2,0(Rx) ;load X(i)
MUL.D F2,F2,F0 ;a × X(i)
L.D F4,0(Ry) ;load Y(i)
ADD.D F4,F4,F2 ;a × X(i) + Y(i)
S.D 0(Ry),F4 ;store into Y(i)
DADDIU Rx,Rx,#8 ;increment index to X
DADDIU Ry,Ry,#8 ;increment index to Y
DSUBU R20,R4,Rx ;compute bound
BNEZ R20,Loop ;check if done
问 How does the order of the code change due to the delayed branch?
老师提示我 Having a delayed branch does not reorder the
code drastically as you have proposed but moves one instruction (since the
delayed branch was one cycle).
So given this new
information, which statement changes its position relative to the BNEZ
statement.
我说把loop里面的第一个Load放到BNEZ后面好让branch delay slot填上,别闲着。这
厮说不对。不知道是不是我没有理解delayed branching,哪位能给再讲解一下。谢了
! |
|