O Pipelining for Unconditional PC-Relative Jumps FDx| M wll target;等同于ja1x0,° offset JDm i pc +=sext(offset) bubble FDX M target: add xl, x2, x3
Pipelining for Unconditional PC-Relative Jumps 27 M W X M W D X M W j target ;等同于 jal x0,offset ; pc +=sext(offset) F D F target: add x1, x2, x3 X D F bubble
Branch Delay Slots 早期的RISC机器的延迟槽技术—改变ISA语义,在分支/跳转后 的延迟槽中指令总是在控制流发生变化之前执行 Ox100 j target 0X104 add x1, X2, X3// Executed before target 0x205 target: xor x1, x1, 7 ·软件必须用有用的工作填充延迟槽( delay slots),或者用显 式的NOP指令填充延迟槽 FDxM target D XM w add x1, x2, x3 FD X MIW target: xor xl, x1,7
Branch Delay Slots • 早期的RISC机器的延迟槽技术—改变ISA语义,在分支/跳转后 的延迟槽中指令总是在控制流发生变化之前执行: – 0x100 j target – 0x104 add x1, x2, x3 // Executed before target – … – 0x205 target: xori x1, x1, 7 • 软件必须用有用的工作填充延迟槽(delay slots),或者用显 式的NOP指令填充延迟槽 28 M W X M W D X M W j target F D F target: xori x1, x1, 7 X D F add x1, x2, x3
Post-1990 RISC ISAS取消了延迟槽 性能问题 当延迟槽中填充了№oPs指令后,增加了- cache的失效率 即使延迟槽中只有一个NOP, cache失效导致机器等待 使先进的微体系架构复杂化 例如4发射30段流水线 较好的分支预测技术减少了采用延迟槽技术的动 力
Post-1990 RISC ISAs 取消了延迟槽 • 性能问题 – 当延迟槽中填充了NOPs指令后,增加了I-cache的失效率 – 即使延迟槽中只有一个NOP,I-cache失效导致机器等待 • 使先进的微体系架构复杂化 – 例如4发射30段流水线 • 较好的分支预测技术减少了采用延迟槽技术的动 力 29
O RISC-V Conditional Branches PCSel B FKill DKill Cond? +4 山 nstruction Cache 切 Fetch Decode EXecute
Decode EXecute Fetch RISC-V Conditional Branches 30 Registers B A Instruction Cache Inst. Inst. Register ALU PC_decode Add Branch? PCSelPC_fetch Kill FKill +4 Cond? PC_execute Add Kill DKill
O Pipelining for Conditional Branches FDX M Wl beg x1,x2,target 川 wI bubble xMl bubble F‖|DX W target: add x1,x2,x3
Pipelining for Conditional Branches 31 M W X M W D X M W F D beq x1, x2, target F target: add x1, x2, x3 X D F bubble bubble F D X M W