Content deleted Content added
better example; add See also section |
Simplified English. Added spacing-- not a great fan of extra spacing but on web pages can be hard to read without. Trust me, I've written a text editor. |
||
Line 9:
However, if too many variables are created, there will be high [[register pressure]], especially on processors with few registers, like the 32-bit [[x86]]. If the compiler runs out of registers, some variables will be [[register spilling|spilled]]. To counteract this, the “opposite” optimization can be performed, [[rematerialization]].
==
If we consider the following code sample, two
<source lang="C">
for (i = 0; i < n;
x = y + z;
a[i] = 6 * i + x * x;
}
</source>
The calculations <code>x = y + z</code> and <code>x * x</code> can be moved outside the loop since within they are [[loop invariant]]&mdahs; they do not change over the iterations of the loop&mdash,
<source lang="C">
x = y + z;
t1 = x * x;
for (i = 0; i < n; i++) {
a[i] = 6 * i + t1;
}
</source>
|