COMPILER DESIGN

INTRODUCTION TO COMPILER DESIGN

OVERVIEW OF COMPILERS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Substitution of values for names whose values are constant, is done in
A
local optimization
B
loop optimization
C
constant folding
D
none of these
Explanation: 

Detailed explanation-1: -In conclusion, the substitution of values for names whose values are constants is an example of constant folding, which is a code optimization technique that can improve the performance, size, and readability of programs.

Detailed explanation-2: -Constant folding is an optimization technique that eliminates expressions that calculate a value that can already be determined before code execution. These are typically calculations that only reference constant values or expressions that reference variables whose values are constant.

Detailed explanation-3: -For example, if you assign x = 5, then y = x, then z = y * 3, then a = x + y + z, and there are no assignments interfering with this, then constant propagation tells as that y = 5, z = 5 * 3 (which turns into z = 15 after constant folding), and a = 25. Instead of just constant values, other values can be propagated.

There is 1 question to complete.