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

Discussion

Constant folding is the optimisation that

  • A.moves loop invariant computations out of the body of the loop
  • B.replaces a repeated subexpression with a reference to a single saved copy
  • C.evaluates at compile time expressions whose operands are all constants
  • D.removes statements that can never be reached during execution

Answer: C

If both operands are known at compile time the compiler can compute the result and substitute it. The runtime cost of the operation disappears entirely, and further optimisations often become possible once the constant is visible.

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

Post your comment

Please log in or register to post a comment.