Re:Jump Threading
by MatzeBraun on Thursday October 29, 2015 @01:44AM
(#10469486)
I am not convinced it's that simple if 1 application of jump threading creates a new opportunity.
The endlessly unreliable loop example in the post suggests that is is a halting problem to find out whether we should stop jump threading because we are unrolling an endless loop or not.
[ Parent
| on HN ]
First, that example is not jump threading, since its cloning code and CFG blocks.
https://en.wikipedia.org/wiki/Jump_threading
is a better description of jump threading.
In what the author describes as jump threading, you have the same problem as loop peeling or any other loop optimization that may get applied to an infinite loop and want to duplicate per-iteration code from that loop.
Yet somehow, as you'll see, we can prove things about the end states of those optimizations. ;-)
Though there's a very pragmatic solution for the compiler: Stop after a fixed number of iterations.
Since it's an optimization, and not required for correct operation of the compiler, one can simply give up instead of risking an infinite loop.