EasyManua.ls Logo

Intel i960 - Constant Propagation

Intel i960
347 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
i960 Processor Compiler User's Guide
11-6
11
Table 11-3 Examples of Identity Collapsing
Original Replacement
a + 0 a
a * 1 a
a * 0 0
x << 0 x
0 >> y 0
Constant Propagation
Programs often contain computations that produce the same value each
time the program is executed. Constant propagation involves tracking
constant values through the computations in a program. In arithmetic or
conditional operations, the compiler can sometimes eliminate less efficient
memory or register instructions, replacing them with an instruction
sequence that uses constant values. The compiler performs the following
types of instruction replacement:
An integer arithmetic instruction that always produces the same
constant value result is replaced by a single instruction (commonly
lda or mov ) that copies the constant value into the destination register
of the original instruction. For example, this program fragment uses
an
addo to put the sum of 2 and 4 into g4:
mov 2, g2
mov 4, g3
addo g2, g3, g4
After constant propagation, the code contains these optimized
instructions:
mov 2, g2
mov 4, g3
mov 6, g4
Dead code elimination deletes the first two now-unused mov
instructions.

Table of Contents

Related product manuals