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

Discussion

In peephole optimization, constant folding involves :

  • A.Combining consecutive loads
  • B.Eliminating dead code
  • C.Folding constant expressions during compilation
  • D.Unrolling loops

Answer: C

Constant folding means folding constant expressions during compilation.

When an expression's operands are all known at compile time, the compiler evaluates it once and replaces it with the result: x = 2 * 3 + 4 becomes x = 10. This saves the computation at run time.

Combining consecutive loads, eliminating dead code and unrolling loops are separate optimisations. Each removes or restructures code, but none computes constant expressions in advance.

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

Post your comment

Please log in or register to post a comment.