# Ullman (Compiler Design) Edition 2 Exercise 6.1 Question 2 (Page No. 363)

248 views

Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming $+$ associates from the left.

1. $a+b+(a+b)$
2. $a+b+a+b$
3. $a+a+((a+a+a+(a+a+a+a))$
0

for part (b)  :  a + b + a + b

DAG is : and Value number table will be:

 1         ID a 2         ID b 3         + 1 2

from this we conclude that :

the value number of + is 3 and its left child has 1 and right child has 2

Is this correct value number table and DAG for (b)? correct me if i am wrong?

## Related questions

1 vote
1
260 views
Construct the DAG for the expression $((x + y)-((x + y)\ast(x -y))) + ((x+y)\ast(x-y))$
Assuming that function $widen$ in Fig. $6.26$ can handle any of the types in the hierarchy of Fig. $6.25(a)$, translate the expressions below. Assume that c and d are characters, $s$ and $t$ are short integers, $i$ and $j$ are integers, and $x$ is a float. $x=s+c$ $i=s+c$ $x=(s+c)\ast(t+d)$
Add to the translation of Fig. $6.19$ rules for the following productions: $E\rightarrow E_{1}\ast E_{2}$ $E\rightarrow + E_{1}\:$(unary plus)