ISRO Scientist/Engineer CSE 2017Compiler Design › Code Optimization and Runtime Environment
ISRO Scientist/Engineer CSE 2017 PYQ: 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 +=…
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?
- AThe code contains loop invariant computation
- BThere is scope of common sub-expression elimination in this code
- CThere is scope of strength reduction in this code
- DThere is scope of dead code elimination in this codeCorrect answer
Answer
(D) There is scope of dead code elimination in this code
Approach
Evaluate each compiler-optimization claim against the given nested-loop code. A claim is false if the described optimization has no applicable opportunity in the code.
Reviewed by ISRO IQ Editorial Team.