Skip to content

GATE CS Local Optimization questions

Practise Local Optimization questions for GATE CS. Explore official PYQs and original topic-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

13 on this page
Official PYQ2026Compiler DesignLocal OptimizationMCQ · 2 marks
Consider the control flow graph given below. Which one of the following options is the set of live variables at the exit point of each basic block?
Official PYQ2025Compiler DesignLocal OptimizationMCQ · 1 mark
Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
Official PYQ2021Compiler DesignLocal OptimizationNAT · 2 marks
Consider the following CC code segment: a = b + c; e = a + 1; d = b + c; f = d + 1; g = e + f; In a compiler, this code segment is represented internally as a directed acyclic graph (DAG)\text{(DAG)}. The number of nodes in the DAG\text{DAG} is _____________
Official PYQ2021Compiler DesignLocal OptimizationMCQ · 2 marks
​​​​​​Consider the following ANSI C\text{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 yy points to a struct\textsf{struct} (allocated on the heap) containing two fields f1\textsf{f1} and …
Official PYQ2015Compiler DesignLocal OptimizationMCQ · 1 mark
In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one of the following is TRUE?
Official PYQ2014Compiler DesignLocal OptimizationMCQ · 1 mark
Which one of the following is FALSE?
Official PYQ2014Compiler DesignLocal OptimizationMCQ · 1 mark
Consider the basic block given below. a = b + c c = a + d d = b + c e = d - b a = e + b The minimum number of nodes and edges present in the DAG representation of the above basic block respectively are
Official PYQ2014Compiler DesignLocal OptimizationNAT · 1 mark
The minimum number of arithmetic operations required to evaluate the polynomial P(X)=X5+4X3+6X+5P(X) = X^5+4X^3+6X+5 for a given value of XX, using only one temporary variable is ______.
Official PYQ2013Compiler DesignLocal OptimizationMCQ · 1 mark
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment. c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; } …
Official PYQ2008Compiler DesignLocal OptimizationMCQ · 1 mark
Some code optimizations are carried out on the intermediate code because
Official PYQ2006Compiler DesignLocal OptimizationMCQ · 1 mark
Consider the following C code segment. for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } } } Which one of the following is false?
Official PYQ2006Compiler DesignLocal OptimizationMCQ · 1 mark
Consider these two functions and two statements S1 and S2 about them. int work1(int *a, int i, int j) { int x = a[i+2]; a[j] = x+1; return a[i+2] - 3; } int work2(int *a, int i, int j) { int t1 = i+2; int t2 = a[t1]; a[j] = t2+1; return t2 - 3; } S1: The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will …
Official PYQ2004Compiler DesignLocal OptimizationMCQ · 1 mark
Consider the grammar rule E→E1–E2E \rightarrow E1 – E2 for arith­metic expressions. The code generated is targeted to a CPU having a single user register. The sub­traction operation requires the first operand to be in the register. If E1E1 and E2E2 do not have any com­mon sub expression, in order to get the shortest possible code