GATE / CS ARCHIVE

GATE CSE 2014 SET 3 / QUESTION 34

GATE CSE 2014 Set 3 Q34

Compiler Design · Code Optimization & Data-Flow Analysis · Full GATE CSE 2014 Set 3 paper

GATE 2014 Set 3, Q34 2 marks · MCQ
Report issue

Code Optimization & Data-Flow Analysis

Question 34, GATE 2014: The basic block executes a=b+c; c=a+d; d=b+c; e=d−b; a=e+b. What are the minimum DAG node and edge counts? A (6,6); B (8,10); C (9,12); D (4,4).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: A with algebraic simplification

Step 1: Preserve old values when tracking assignments: let the input leaves be b0,c0,d0. The first three operations create u=b0+c0, v=u+d0, w=b0+v. The current c is v and current d is w. Step 2: Algebraically, e=w−b0=(b0+v)−b0=v, and final a=e+b0=v+b0=w. Therefore e shares v's node and a shares w's node. Step 3: The minimized DAG has three input leaves and three binary addition nodes: six nodes. Each operation has two incoming operand edges, giving six edges, A. Without cancellation, a purely syntactic DAG gives eight nodes and ten edges. The keyed minimum assumes valid algebraic identities, not unrestricted floating-point cancellation.

Original paper, page 60 · Answer key