Machine-translated by Google. Questions are authored in English.
Top

Discussion

Loop invariant code motion moves a computation

  • A.out of the loop when its operands do not change within it
  • B.into the loop so it is computed as late as possible
  • C.down to the end of the procedure
  • D.into a separate procedure that the loop then calls

Answer: A

Correct answer: out of the loop when its operands do not change within it

If nothing the computation depends on is modified inside the loop, the result is the same on every iteration and it can be computed once in a preheader. The payoff is proportional to the trip count, which makes this one of the most valuable loop transformations, and it depends on data flow analysis to establish that the operands really are invariant.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.