This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnrolling] Do not expand unsafe expressions in loop unrolling
AbandonedPublic

Authored by mkazantsev on Oct 24 2017, 4:43 AM.

Details

Summary

When using SCEVExpander, passes are obliged to make sure that what they request
to expand is safe in terms of expander. We are going to enforce this adding an assert
that it is safe to expand what we request. Currently it causes a failure of one unrolling
test at which we expect unroller to expand division by a value which is potentially zero.

Despite it might be OK to do so because of UB effect of division by zero, we need to
comply with expander's requirements. This patch prohibits expanding unsafe expressions
in loop unrolling. We also make sure that we know that denominator is non-zero, it is
OK to expand such an expression and unroll the loop.

Diff Detail