djrieger / mjplusplus

A compiler for the MiniJava language
http://djrieger.github.io/mjplusplus/doc/doxygen/html/
6 stars 1 forks source link

Separate constant folding and arithmetic simplification (unless the arithmetic simplification makes values constant) #101

Closed ratefuchs closed 9 years ago

ratefuchs commented 9 years ago

Using x - 0 = x or x*(-1)=-x should not be done during constant folding (separation of concerns...).

We should only incorporate those arithmetic identities which produce a constant value like x * 0 = 0 or x % 1 = 0. Explicit simplification should be unnecessary because those are used implicitly on tarval computation and the tarval then signals constness, which leads to replacement during the normal constant folder cleanup.