In compiler optimization, operator strength reduction uses mathematical…

2016

In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction?

  1. A.

    Replace P + P by 2 * P or Replace 3 + 4 by 7

  2. B.

    Replace P * 32 by P << 5

  3. C.

    Replace P * 0 by 0

  4. D.

    Replace (P << 4) − P by P * 15

Attempted by 46 students.

Show answer & explanation

Correct answer: B

Operator strength reduction replaces expensive arithmetic operations with cheaper equivalents in compiler optimization. A classic example is replacing multiplication by a power of two, like P * 32, with a bitwise shift operation such as P << 5. This transformation improves execution speed without changing the program's logic.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor