# Recent questions tagged code-optimization 1
Which of the following is machine independent optimization? Loop optimization Redundancy Elimination Folding All of the option
2
The optimization phase in a compiler generally Reduces the space of the code Optimizes the code to reduce execution time Both (A) and (B) Neither (A) nor (B)
1 vote
3
Replacing the expression $4\ast 2\cdot 14$ by $8 \cdot 56$ is known as constant folding induction variable strength reduction code reduction
4
Consider the statement do { i = i + 1; } while ( a[i] < b ); The minimum number of variables required in the three address code of the above statement ?
5
A sequential search operation is performed on an array $A$ for the key value of $'x'$ (ignore quotes). Consider the following piece of assembly language code that uses back patching to perform the sequential search. i=0; P: if (i<A.length) goto ____; Q: goto ____; R: if (x==A[i] ... What should be the correct values in the blanks provided ordered from top to bottom? R T U P R U T P P U T R P T U R
6
Given the 3-address code for a basic block: The number of registers that are needed to allocate this basic block with no spills are ________.? My doubt here is : Is there any difference in question asking for minimum numbers of registers and minimum number ... If the question ask for minimum number of variables required in three address code, Only then should we optimize the code before counting?
7
8
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 ? A. Replace P + P by 2 * P or Replace 3 + 4 by 7 B. Replace P * 32 by P < < 5 C. Replace P * 0 by 0 D. Replace (P < <4) – P by P * 15 pls explain your answer
9
DU-chains(Definition-Use) in compiler design: consist of a definition of a variable and all its uses, reachable from that definition are created using a form static code analysis are prerequisite for many compiler optimization including constant propagation and common sub-expression elimination All of the above
10
Which of the following comment about peep-hole optimization is true? It is applied to small part of the code and applied repeatedly It can be used to optimize intermediate code It can be applied to a portion of the code that is not contiguous It is applied in symbol table to optimize the memory requirements.
11
12
i got 5 and 4 but given ans is 6 and 6. How??
13
I'm getting 8,10 but the answer given is 6,6
14
I got answer 8 nodes and 10 edges. but answer is 6 nodes and 6 edges anyone plz explain.
15
Consider the code segment int i,j,x,y,m,n; n = 20; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i%2) { x += ((4*j)+5*i); y += (7+4*j) } } } m=x+y; Which one of the following is false? The code contains loop invariant computation There is scope of common sub-expression elimination in this code There is scope of strength reduction in this code There is scope of dead code elimination in this code
16
I'm getting 4 nodes and 5 edges. But the answer given is : 6 nodes and 7 edges
17
Consider the following source code : c = a + b d = c c = c – e a = d – e b = b * e b = d/b (A) No optimization is possible (B) d = c c = c – e a = d – e b = b * e b = d/b (C) c = a + b d = c c = c – e a = d – e b = d/b (D) c = a + b t = b * e a = d – e b = d/t c = a
18
Please can anyone list the topics to study in this part. The syllabus only states basics of code generation and optimization. Anyone who had prepared gate earlier. What did you study?
1 vote
19
What is the difference between Cross Compiler and Bootstrapping ?
20
Please explain what is Global Data Flow Analyis in Code optimization ?
21
Anyone please tell what is Peephole Optimization withan easy exmaple ??
22
Peephole optimization is form of Loop optimization Local optimization Constant folding Data flow analysis
1 vote
23
Consider the following code which computes the inner product of 2 vectors: prod := 0; i := 1; repeat { prod := prod + a[i] * b[i] i = i+1; until i >20 } Below is possible IR for this program : 1) prod := 0 2) i :=1 3) t1 :=4*i 4) t2 :=a[t1] 5) t3 := ... 10)t7 := i+1 11) i :=t7 12) if i<=20 goto (3) 13) .. Create Basic Blocks and the control Flow Graph and also show any Optimizatioions.If you Find.
24
Which of the following statements about peephole optimization is False? It is applied to a small part of the code It can be used to optimize intermediate code To get the best out of this, it has to be applied repeatedly It can be applied to the portion of the code that is not contiguous
25
In compiler terminology reduction in strength means Replacing run time computation by compile time computation Removing loop invariant computation Removing common subexpressions replacing a costly operation by a relatively cheaper one
26
Substitution of values for names (whose values are constants) is done in Local optimization Loop optimization Constant folding Strength reduction
1 vote
27
In compiler design &lsquo;reducing the strength&rsquo; refers to reducing the range of values of input variables code optimization using cheaper machine instructions reducing efficiency of program none of the above