Assume the following execution time for different operations: MUL takes 6 cycles, DIV takes 15 cycles, and ADD and SUB both take 1 cycle to complete. The instructions are issued into the pipeline in order, but out of order execution and completion is allowed. What hazards will be encountered when executing this code sequence?
MUL F1, F3, F2
ADD F2, F7, F8
DIV F10, F1, F5
SUB F5, F8, F2
SD 8(R1), F2
(A) No hazards for this code sequence
(B) There will be a data hazard when the ADD instruction is executed.
(C) There will be a data hazard when the SD instruction is executed
(D) There will be a data hazard when the DIV instruction is executed.
(E) A Write After Read (WAR) hazard is possible when SUB instruction completes execution.
(A) 下面 (D)(E) 成立 → F
(B) ADD 讀 F7、F8,前面沒有指令寫這兩個暫存器;它寫 F2 與 MUL 讀 F2 是 name dependence(WAR),不是 RAW 的 data hazard → F
(C) SD 要的 F2 由 ADD 產生,ADD 只要 1 cycle,SD 是第 5 個才 issue,值早已寫好 → F
(D) DIV 讀 F1,F1 要等 MUL 跑滿 6 cycle,DIV 是第 3 個 issue → RAW → T
(E) DIV 要 15 cycle 才讀完 F5 之後完成,SUB 只要 1 cycle,out-of-order completion 時 SUB 可能在 DIV 讀 F5 之前就寫掉 F5 → WAR → T
(D), (E)