In these hand-in questions we will look at pipeline issues.
Read about forwarding, and then attempt the questions.
add %r5, %r4, %r2 add %r2, %r5, %r4 st %r5, [%r2+4] add %r2, %r4, %r3 add %r3, %r5, %r5
add %r1, %r4, %r3 ld [%r3], %r2 add %r1, %r2, %r4 sub %r4, %r2, %r2 add %r1, %r4, %r2
How many cycles will it take to execute this code?
The original code
top: add %r4, %r3, %r4 subcc %r2, 1, %r2 bg top nopThe converted code
top: subcc %r2, 1, %r2 bg top add %r4, %r3, %r4
loop: ld [%r1], %r3 add %r3, %i2, %r3 st %r3, [%r1] ld [%r1-4], %r4 add %r4, %r2, %r4 st %r4, [%r1-4] add %r1, -8, %r1 subcc %r1, %r0, %r0 bne loop nopAssume that forwarding is available, and reorder the code so that it has the same semantics (the same effect on the machine including all data registers and memory locations), but so that it will run faster on the standard pipeline.
| Kate and Mike, 2013. | COMP226 home page |