Fix various issues with constant condition elimination
authorMikko Rasa <tdb@tdb.fi>
Sat, 25 May 2019 21:00:54 +0000 (00:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 25 May 2019 21:20:54 +0000 (00:20 +0300)
commitaa9873652630db493b5bd9faee4117e9c30ef226
tree0964a497f1bbd8fde9b8144c4ba21ac433052796
parente37d3b91500994df3de4fe47bd3d3e75d3104b46
Fix various issues with constant condition elimination

It used to optimize based on the initial values of variables, ignoring
the fact that they may change between loop iterations.  A stop-gap fix
was implemented in 8e14c29, but it prevented optimizations of some
conditionals that could safely have been removed.  It also caused the
optimizer to ignore any assignments made to any variables after
declaration when evaluating the loop condition, potentially causing
entire loops to be erroneously removed.  Finally, unary expressions were
not being handled so ++ and -- operators did not mark the variable as
modified.
source/programcompiler.cpp
source/programcompiler.h