We should really rethink our current approach on constant folding/propagation. We should not exchange nodes during analysis. A better approach would be:
Set all tarvals to unknown.
Run fixpoint analysis for constant folding / propagation.
Exchange all constant nodes (maybe check if they still exist; we need to see whether this check is necessary).
This would mean we
don't have problems with updating tarvals for new nodes
don't need special cases for constant folding because it gets incorporated within the normal constant propagation
could optimize the x=1; while (...) x=2-x; loop
I think this could maybe also help eliminating the problems with our current phi optimization (#88 and #89).
Arithmetic identities (when not producing constants like 0*x), elimination of unreachable code and other optimization steps may be separated from constant analysis (and all optimizations can be repeated until they have a definite fixpoint or maybe a certain repetition threshold is reached).
We should really rethink our current approach on constant folding/propagation. We should not exchange nodes during analysis. A better approach would be:
This would mean we
x=1; while (...) x=2-x;
loopI think this could maybe also help eliminating the problems with our current phi optimization (#88 and #89).
Arithmetic identities (when not producing constants like 0*x), elimination of unreachable code and other optimization steps may be separated from constant analysis (and all optimizations can be repeated until they have a definite fixpoint or maybe a certain repetition threshold is reached).