Optimization and Data Flow questions

Q30

GATE CS 2021 CS-2Optimization and Data FlowMCQ2 marks−2/3 if wrong
Consider the following ANSI C code segment:
z = x + 3 + y->f1 + y->f2;
for (i = 0; i < 200; i = i + 2){
    if (z > i) {
        p = p + x + 3;
        q = q + y->f1;
    } else {
        p = p + y->f2;
        q = q + x + 3;
    }
}
Assume that the variable y points to a struct (allocated on the heap) containing two fields f1 and f2, and the local variables x, y, z, p, q, and i are allotted registers. Common sub-expression elimination (CSE) optimization is applied on the code. The number of addition and dereference operations (of the form y->f1 or y->f2) in the optimized code, respectively, are:
Show answer without attempting

Answer: D

Q38

GATE CS 2021 CS-2Optimization and Data FlowMCQ2 marks−2/3 if wrong
For a statement SS in a program, in the context of liveness analysis, the following sets are defined:

<br>USE(S):the set of variables used in S<br>IN(S):the set of variables that are live at the entry of S<br>OUT(S):the set of variables that are live at the exit of S<br>\begin{array}{rll}<br>\text{USE}(S) & : & \text{the set of variables used in } S \\<br>\text{IN}(S) & : & \text{the set of variables that are live at the entry of } S \\<br>\text{OUT}(S) & : & \text{the set of variables that are live at the exit of } S<br>\end{array}

Consider a basic block that consists of two statements, S1S_1 followed by S2S_2.
Which one of the following statements is correct?
Show answer without attempting

Answer: A

0/20 correct0 marks

Related topics in Compiler Design