11
Register Use
11-16
i960 Processor Compiler User's Guide
Variable Shadowing
The compiler may place a memory object in a register throughout a
single-entry, single-exit region (such as a loop) when it can determine that
the following are all true:
•
There are no references to memory within the region that could
overlap the candidate memory object.
•
The address of the candidate is a compile-time constant, or it is
constant throughout the single-entry, single-exit region and a
reference to the object's address is guaranteed to happen at least once
whenever the code for the region is executed.
•
There are no calls within the region.
In the following example, global migration causes
the beginning of the loop and stored once at the exit point.
static int*p;
while (*p != '\0')
p++;
Without this optimization, the program loads and stores
iteration of the loop.
The compiler can use registers to speed up data access. Register
optimizations are as follows:
•
local variable promotion
•
register management
•
register spilling
to be loaded once at
p
once for each
p