Question: 3 Problem - Compiler Optimization and Aliasing Assume the following program fragment without any control flow branches (straight line code). Your job is to implement
3 Problem - Compiler Optimization and Aliasing
Assume the following program fragment without any control flow branches (straight line code). Your job is to implement a compiler optimization called "constant folding" for straight line code. This optimization identifies program variables with values that are known at compile time. Expressions that consist of only such variables can be evaluated at compile time. In our project, we do constant folding for ILOC instructions, not on the source code itself.
Would it always be safe for the compiler optimization of constant folding to replace the assignment "c = a-b" by "c = 1" ? Note that there are no assignments to variables a or b between "b = 3" and "c = a-b" The control flow is linear, so there are no branches. Give an example where constant propagation would not be safe (incorrect) in this situation, without violating any of the above assumptions about the code fragment. Note: You can add declarations of other variables and other statements that do not mention a or b.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
