Loop-invariant Code Motion - Benefits

Benefits

Loop-invariant code which has been hoisted out of a loop is executed less often, providing a speedup. Another effect of this transformation is allowing constants to be stored in registers and not having to calculate the address and access the memory (or cache line) at each iteration.

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 spilled. To counteract this, the inverse optimization can be performed, rematerialization.

Read more about this topic:  Loop-invariant Code Motion

Famous quotes containing the word benefits:

    It is too late in the century for women who have received the benefits of co-education in schools and colleges, and who bear their full share in the world’s work, not to care who make the laws, who expound and who administer them.
    J. Ellen Foster (1840–1910)

    One of the benefits of a college education is, to show the boy its little avail.
    Ralph Waldo Emerson (1803–1882)

    It is with benefits as with injuries in this respect, that we do not so much weigh the accidental good or evil they do us, as that which they were designed to do us.—That is, we consider no part of them so much as their intention.
    Laurence Sterne (1713–1768)