Similar questions 2 more →
Code Optimization & Data-Flow Analysis

Answer & solution
Official answer: A
Givens and goal
Blocks execute B1: a=b+c; B2: d=a+e; B3: e=a+f; B4: g=d+e. Edges are entry→B1, B1→B2, B1→B3, B2→B4, B3→B1, B4→exit. No variable is live after exit. Candidate exit sets (B1,B2,B3,B4) are A ({a,b,c,e,f},{d,e},{b,c,e,f},∅); B (∅,{d,e},{a,c,f},∅); C ({a,b,c,e,f},{d,e},{c,e,f},∅); D (∅,{d,e,f},{a,b,c,e,f},∅).
Approach
Solve backward liveness equations to a fixed point, including the loop edge.
Step-by-step solution
1. For each block, OUT is the union of successor IN sets; IN=USE∪(OUT−DEF). Here USE/DEF are B1:{b,c}/{a}, B2:{a,e}/{d}, B3:{a,f}/{e}, and B4:{d,e}/{g}.
2. OUT4=∅, so IN4={d,e}. Hence OUT2={d,e} and IN2={a,e}∪({d,e}−{d})={a,e}.
3. The loop equations are OUT3=IN1, IN3={a,f}∪(IN1−{e}), OUT1=IN2∪IN3, and IN1={b,c}∪(OUT1−{a}). Starting empty and propagating produces the least fixed point IN1={b,c,e,f} and IN3={a,b,c,f}.
4. Substitute back to check: OUT1={a,e}∪{a,b,c,f}={a,b,c,e,f}; removing a and adding b,c indeed gives IN1={b,c,e,f}. OUT3=IN1={b,c,e,f}; removing e and adding a,f indeed gives IN3={a,b,c,f}.
5. The requested exit sets are therefore OUT1={a,b,c,e,f}, OUT2={d,e}, OUT3={b,c,e,f}, OUT4=∅, matching A. In particular b stays live through B3 because the loop can return to B1 and read b before any redefinition.
6. The source assignments and all arrows were inspected visually. Ignoring the back edge would incorrectly remove values needed on a later loop iteration.