Re:Check Widening in LLVM
by tedunangst on Sunday July 17, 2016 @12:41PM
(#12110726)
Thanks. I think I understand, but would have liked to see the lowered version with the reused/rewritten condition.
Re:Check Widening in LLVM
by sanjoy_das on Sunday July 17, 2016 @03:54PM
(#12111507)
Is this what you're looking for: http://www.playingwithpointers.com/check-widening-in-llvm.ht... ?
In other words, the general optimization is to convert
to: i.e., that we can assume an if-condition is true within the body of that if-statement. The problem is that the check-widening reuses the body of the if-statement: the code is converted by check-widening to the first snippet above, which then becomes the second. Sanjoy's observation is that guard-widening is almost correct (we still want to pursue this route) because `f` (the deoptimization escape) is really what we want to call in both cases, but we just need to get the value of `A` right by somehow letting the optimizer know that we're reusing the if-body and that it can't assume anything about the condition that got us there.Also, this is really really clever and I enjoyed the post, OP!