Constant Propagation in Task 1 of Sheet 4

Moderator: Implementing code analyses for large software systems

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

Constant Propagation in Task 1 of Sheet 4

Beitrag von alexandergreat524 »

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
Erstie
Beiträge: 16
Registriert: 8. Okt 2013 22:43

Re: Constant Propagation in Task 1 of Sheet 4

Beitrag von Vespertine »

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
Erstie
Beiträge: 11
Registriert: 30. Okt 2014 13:29

Re: Constant Propagation in Task 1 of Sheet 4

Beitrag von Johannes Spaeth »

Hi,

yes, Vespertine is absolutely right!

Cheers,

Johannes

Antworten

Zurück zu „Implementing code analyses for large software systems (ICA)“