I have been playing with imcc's optimization and have a question about it. With -O2 we get the following results for various inputs:
----------------------------(results 1, invariant removed from loop) .sub _main set I0, 5 loop: set I1, 2 add I0, I1 lt I0, 20, loop print I0 end .end vvvvvvvvvvvvvvvvvvvvvvvvv _main: set I0, 5 set I1, 2 loop: add I0, I1 lt I0, 20, loop print I0 end
---------------------------------(results 2, invariant not removed) .sub _main set I0, 5 loop: set I1, 2 add I0, I1 lt I0, 20, loop print I0 print I1 end .end vvvvvvvvvvvvvvvvvvvvvvvvvvv _main: set I0, 5 loop: set I1, 2 add I0, I1 lt I0, 20, loop print I0 print I1 end
The debug data helpfully tells me that it is because of reason 10, which means less than nothing to me, but gave me a place to look in the source.
Changing line 1096 from
return what == CHK_CLONE ? 1 : (reason=10,0);
to
return 1;
works, but that seems like it is probably the wrong answer. Anyone want to give me a hint why this is happening and possibly add the above as a test?
Thanks, Matt