Consider the following code fragment: if K > 10 L: = K + 1 else L: =

Question:

Consider the following code fragment:
if K > 10
L: = K + 1
else
L: = K - 1;
A straightforward translation of this statement into SPARC assembler could take the following form:
Consider the following code fragment:
if K > 10
L: = K

The code contains a nop after each branch instruction to permit delayed branch operation.
a. Standard compiler optimizations that have nothing to do with RISC machines are generally effective in being able to perform two transformations on the foregoing code. Notice that two of the loads are unnecessary and that the two stores can be merged if the store is moved to a different place in the code. Show the program after making these two changes.
b. It is now possible to perform some optimizations peculiar to SPARC. The nop after the ble can be replaced by moving another instruction into that delay slot and setting the annul bit on the ble instruction (expressed as ble,a L1). Show the program after this change.
c. There are now two unnecessary instructions. Remove these and show the resulting program.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: