Construct the DAG for the basic block
d = b * c
e = a + b
b = b * c
a = e - d
Simplify the three-address code of Exercise 8.5.1, assuming
Only a is live on exit from the block.
e = a + b
d = b * c
a = e - d
a, b, and c are live on exit from the block.
e = a + b
b = b * c
a = e - b
Construct the basic block for the code in block B6 of Fig. 8.9. Do not forget to include the comparison i <= 10.
Construct the DAG for the code in block B3 of Fig. 8.9.
Extend Algorithm 8.7 to process three-statements of the form
Construct the DAG for the basic block
a[i] = b
*p = c
d = a[j]
e = *p
*p = a[i]
on the assumption that
8.5.6 节讲指针赋值这里又没有 demo 啊！！！
*p = c
和 c = *p
翻译成 DAG 是不是这样的：*p = a[i]
这样的语句用 DAG 如何表示？If a pointer or array expression, such as a[i] or *p is assigned and then used, without the possibility of being changed in the interim, we can take advantage of the situation to simplify the DAG. For example, in the code of Exercise 8.5.6, since p is not assigned between the second and fourth statements,the statement e = *p can be replaced by e = c, regardless of what p points to. Revise the DAG-construction algorithm to take advantage of such situations, and apply your algorithm to the code of Example 8.5.6.
Suppose a basic block is formed from the C assignment statements
x = a + b + c + d + e + f;
y = a + c + e;
three-address statements
t1 = a + b
t2 = t1 + c
t3 = t2 + d
t4 = t3 + e
t5 = t4 + f
x = t5
t6 = a + c
t7 = c + e
y = t6 + t7
optimized statments
t1 = a + c
t2 = t1 + e
y = t2
t3 = t2 + b
t4 = t3 + d
t5 = t4 + f
x = t5