EasyManua.ls Logo

Intel i960 - Page 297

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...
Optimization
11-7
11
A conditional branch instruction for which the condition is known is
deleted. For example, this program fragment sets
x equal to y+z if 2
and 4 are equal, which is never true:
a=2; b=4;
...
if (a==b)
x=y+z;
else
x=y-z;
After constant propagation, the code contains these optimized
instructions:
a=2; b=4;
...
if (0)
x=y+z;
else
x=y-z;
Dead-code elimination further reduces the instruction sequence by
removing the test and unreachable "then" part, leaving:
a=2; b=4;
x=y-z;
A conditional branch instruction for which the condition is found to
always be true is changed to an unconditional branch. For example,
this program fragment branches to
L1 if 2 is less than or equal to 4,
which is always true:
Before After
mov 2, g2
mov 4, g3
cmpi g2, g3
ble L1
addi g4, g5, g6
b L2
L1:
subi g4, g5, g6 subi g4, g5, g6
L2: L2:

Table of Contents

Related product manuals