GATE Computer ScienceModerateGATE CS (PYQ pattern)
A basic block has 8 three-address statements, of which 3 compute a triple identical to an earlier one. A compiler stores it as (i) quadruples, one row of 4 fields per statement, and (ii) indirect triples, where each distinct triple is stored once with 3 fields and each statement has a 1-word pointer. What are the totals of fields/words for (i) and (ii)?
- A. 32 and 32
- B. 32 and 23
- C. 24 and 23
- D. 32 and 24
Correct answer: B. 32 and 23
Quadruples: 8 × 4 = 32. Indirect triples: 5 unique triples × 3 = 15 plus 8 pointers = 23, so the sharing and reordering ability costs 8 pointer words but saves duplicates.
More Compiler Design questions
- In 1: a = 1; 2: b = 2; 3: if p > 0 goto L1; 4: a = a + 1; 5: goto L2; 6: L1: b = b + 1; 7: L2: c = a + b; 8: if c > q goto L3; 9: a = c…
- In the loop 1: i = 0; 2: j = 5; 3: L1: t1 = i 4; 4: t2 = t1 + b; 5: j = j + 3; 6: k = j 2; 7: m = m 2; 8: u = i + n; 9: i = i + 1; 10: if…
- With instructions OP R, R and OP R, M (a leaf that is a right child can be a memory operand), the Sethi-Ullman algorithm labels a left…
- For S′ → S; S → ( L ) | x; L → S | L , S, LALR(1) is formed by merging canonical LR(1) states with equal cores. The LALR state reached…
- int j = 2; int A[0..4] = {0, 3, 1, 4, 2}; int Sum(k, lo, hi, e) { int s = 0; for (k = lo; k <= hi; k++) s = s + e; return s; } All…
- An SLR(1) shift-reduce parser for E → E + T | T; T → T F | F; F → ( E ) | id parses "( id + id ) id". Each shift and each reduce counts as…