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

Discussion

A loop executes 1000 times and contains an invariant computation costing 3 instructions. How many instructions does hoisting it save?

  • A.3000
  • B.1000
  • C.3
  • D.2997

Answer: D

The computation runs once instead of a thousand times, so 999 executions of 3 instructions are saved, that is 2997. The hoisted copy still costs 3 instructions in the preheader. The saving grows in direct proportion to the trip count of the loop.

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

Post your comment

Please log in or register to post a comment.