## Constant Propagation in Task 1 of Sheet 4

alexandergreat524
Neuling
Beiträge: 8
Registriert: 6. Nov 2014 18:38

### Constant Propagation in Task 1 of Sheet 4

In an assignment statement, we could easily know that y = 1 (rhsOp instanceof NumericConstant) and x = y(.f) (rhsOp instanceof Local/FlowAbstraction) will lead to constant propagation. But what about z = x + y? If both x and y are constants before the operation, will z be also a constant? If yes, we do not know how to get the final value of z and store it in the Map <FlowAbstraction, NumericConstant>. Because it is not suggested to keep the not-calculated expression x + y in NumericConstant.

Vespertine
Erstie
Beiträge: 16
Registriert: 8. Okt 2013 22:43

### Re: Constant Propagation in Task 1 of Sheet 4

Hi,

(I'm just a student myself so my answer might be wrong). Certainly z will be constant as well if you have constant values associated with x and y. One possibility to get the result is to make use of the class NumericConstant (in this case add()).

Johannes Spaeth
Erstie
Beiträge: 11
Registriert: 30. Okt 2014 13:29

### Re: Constant Propagation in Task 1 of Sheet 4

Hi,

yes, Vespertine is absolutely right!

Cheers,

Johannes