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

Discussion

In compiler terminology reduction in strength means

  • A.Replacing run time computation by compile time computation
  • B.Removing loop invariant computation
  • C.Removing common subexpressions
  • D.Replacing a costly operation by a relatively cheaper one

Answer: D

Reduction in strength means replacing a costly operation by a relatively cheaper one.

A typical example is replacing a multiplication by a loop index with an addition carried through the loop, or x * 2 with a shift or x + x. The result is the same but the operation is cheaper.

Replacing run-time computation by compile-time computation is constant folding, removing loop-invariant computation is code motion, and removing common subexpressions is a separate optimization.

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

Post your comment

Please log in or register to post a comment.