Skip to content

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?

  1. A
    The code contains loop invariant computation
  2. B
    There is scope of common sub-expression elimination in this code
  3. C
    There is scope of strength reduction in this code
  4. D
    There is scope of dead code elimination in this code
    Correct 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.