[GuardUtils] Add asserts about loop varying widenable conditions
We have now seen two miscompiles because of widening widenable conditions at incorrect IR points and thereby changing a branch's loop invariant condition to a loop-varying one (see PR60234 and PR61963). This patch adds asserts in common guard utilities that we use for widening to proactively catch these bugs in future. Note that these asserts will not fire if we were to sink a widenable condition from out of a loop into a loop (that's also incorrect for the same reason as above). Tested this without the fix for PR60234 (guard widening miscompile) and confirmed the assert fires. WARNING: Sometimes, the assert can fire if we failed to hoist the invariant condition out of the loop. This is a pass-ordering issue or a limitation in LICM, which would need an investigation. See details in review. Differential Revision: https://reviews.llvm.org/D147752
Loading
Please sign in to comment