3 ms·
Which is easier to decode? [jmp nop nop], [addi xxx] OR [xxx jmp], [nop nop addi] OR [xxx jmp], [unused, addi] All of these tie up your entire decoder, bu
by hajile 3y ago
Which is easier to decode?
[jmp nop nop], [addi xxx]
OR
[xxx jmp], [nop nop addi]
OR
[xxx jmp], [unused, addi]
All of these tie up your entire decoder, but some tie it up with potentially useful information. That seems superior to me.
- phire 3y agoIt's only unconditional jumps that might have NOPs following them. For conditional jumps (which are pretty common), the extra instructions in the packet will be executed whenever the branch isn't taken. And instruction scheduling can actually do some optimisation here. If you have a loop with an unconditional jump at the end and an unaligned target, you can do partial loop unrolling, for example: With [xxx, inst_1, inst_2], [inst3]...(loop body) ...[jmp to inst_1, nop, nop], you can repack the final jump packet as [inst_1, inst_2, jump to inst_3] This partial loop unrolling actually is much better for performance than not wasting I-cache as it has reduces the number of instruction decoder packets per iteration by one. Compilers will implement this anyway, even if you do support mid-packet jump targets. Finally, compilers already tend to put nops after jumps and returns on current ISAs, because they want certain jump targets (function entry points, jump table entries) to be aligned to cache lines.