[GuardWidening] Choose right point for generating wide condition for branches. PR60234
When guards are represented as widenable branches, there is a tricky situation when the branch stays in loop but widenable condition doesn't. It means that the widenable condition is loop-invariant, and some other optimizations could have done changes using this fact. If widening is allowed to create widened condition inside this loop, and join the loop-invariant wc with some non-invariant facts, it can cause miscompile. See example of this at https://github.com/llvm/llvm-project/issues/60234. The solution is to adjust the point of generationg the wide condition, and therefore of hoisting all related parts there. It should not be before the branch, but before the widenable_condition call. The fact that `wc()` and the wide condition are in the same block guarantees that they will not violate the invariance property for any loop. Differential Revision: https://reviews.llvm.org/D142693 Reviewed By: apilipenko
parent
ff96267b
Please register or sign in to comment