Question: Consider the code below: 1 . X = 2 ; 2 . Y = 1 0 ; 3 . if ( X < Y )
Consider the code below:
X ;
Y ;
if X Y goto
A Y ;
B X A;
Z ;
if B Z goto
D Y Z ;
Z Z ;
goto ;
X X ;
goto ;
Y D;
halt;
a Draw the CFG for the code and identify the loops in the code.
b Does the code contain any loop invariant statements? If yes, then write them out separately. Move the loop invariant statements outside their enclosing loop? Rewrite the code after hoisting any loop invariant code outside the loop.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
