Consider the following code fragment: if K > 10 L: = K + 1 else L: =
Question:
if K > 10
L: = K + 1
else
L: = K - 1;
A straightforward translation of this statement into SPARC assembler could take the following form:
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.
Step by Step Answer:
Computer organization and architecture designing for performance
ISBN: 978-0136073734
8th edition
Authors: william stallings