Here is Gries Method example 1.  Notice that triples sometimes are not emitted because they involve redundant expressions.

 

D = D + C * B;

A = D + C * B;

C = D + C * B;

 

Triple

 

valnum

c

d

redundant

optimized

(1)

* C B

3

n

y

 

* C B

(2)

+ D (1)

5

n

y

 

+ D (1)

(3)

= D (2)

 

 

 

 

= D (2)

(4)

* C B

3

n

n

(1)

 

(5)

+ D (4)

6

n

y

 

+ D (1)

(6)

= A (5)

 

 

 

 

= A (5)

(7)

* C B

3

n

n

(1)

 

(8)

+ D (7)

6

n

n

(5)

 

(9)

= C (8)

 

 

 

 

= C (5)

 

op

v1

v2

*

1

2

+

4

3

+

5

3

 

 

Avail Computations Table                Symbol Table

triple          valnum p                  A - 6

(1) * 1 2          3                       B - 2

(2) + 4 3          5                       C – 1 replaced by 6

(3) + 5 3          6                       D – 4 replaced by 5

 

At end:

 

next i = 10

next v = 7

next p = 4