This is an archive of the discontinued LLVM Phabricator instance.

[IRCE] Ensure that expanded exit values are available in loop's preheader
AbandonedPublic

Authored by mkazantsev on Oct 25 2017, 10:47 PM.

Details

Summary

This patch adds a check that SCEV of main and preloop exit conditions are available in
predecessor where they are expanded. In theory, this may be broken if these values
depend on SCEVUnknown which cannot be expanded to preheader. In practice, such
cases get rejected earlier, but this may change in future.

Diff Detail

Event Timeline

mkazantsev created this revision.Oct 25 2017, 10:47 PM
reames requested changes to this revision.Oct 26 2017, 9:27 AM
reames added inline comments.
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
1468

To avoid confusion, call this something like MainL or OriginalL.

1485

Put these in the other order so that we don't run isSafeToExpandAt if the value is not available. I don't know that it currently does, but isSafeToExpandAt could reasonable have a precondition that the location is available. :)

1512

Same.

test/Transforms/IRCE/bad_expander.ll
169

What is this trying to test? The potentially faulting load doesn't contribute to any latch or range check, so how would it show up in the split value?

200

Same problem.

This revision now requires changes to proceed.Oct 26 2017, 9:27 AM
mkazantsev added inline comments.Oct 26 2017, 9:54 PM
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
1485

We invoke isSafeToExpandAt for loop's preheader. From within this function, we don't have any information about the fact that our insertion point is connected to some loop, and whether it is important for us or not. The loop in this particular case is important because we know that we are going to use the expanded value as the entry value of some loop's Phi; in general case, we don't always do so so shouldn't always care about loops in expander.

mkazantsev abandoned this revision.Feb 26 2018, 2:56 AM