Real Time Systems Design And Analysis

Untitled Document

7.6.11   Constant Propagation

Certain variable assignment statements can be changed to constant assignments,
thereby permitting registerization opportunities or the use of immediate modes.
In C, the following code might appear as the result of an automated translation
process:

x=100;
y=x;


The corresponding 2-address assembly language code generated by a nonoptimizing
compiler might look like:

LOADR1,100
STORER1,&x
LOADR1,&x
STORER1,&y

This could be replaced by

x =100;
y = 100;


With associated 2-address assembly output:

LOADR1,100
STORER1,&x
STORER1,&y

Again, this type of code often appears during mechanical translation form one
language to another.


7.6.12  Dead-Store Elimination

Variables that contain the same value in a short piece of code can be combined
into a single temporary variable. For example,

t=y+z;
x=func(t);

Although many compilers might generate an implicit temporary location for
y+z, this cannot always be relied on. By replacing the code in question with
the following:

x=func(y+z);

forces the generation of a temporary location and eliminates the need for the
local variable, t.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: PCMCIA Memory Cards
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.