This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Drop check for the validity of rewrite
ClosedPublic

Authored by lebedev.ri on Aug 24 2021, 12:10 PM.

Details

Summary

isValidRewrite() checks that the both the original SCEV,
and the rewrite SCEV have the same base pointer.
I believe, after all the recent SCEV improvements,
this invariant is already enforced by SCEV itself.

I originally tried changing it into an assert in D108043,
but that showed that it triggers on e.g. https://reviews.llvm.org/D108043#2946621,
where SCEV manages to forward the store to load.

@efriedma @mkazantsev @reames does my understanding i outlied above match the current state of reality?

Diff Detail

Event Timeline

lebedev.ri created this revision.Aug 24 2021, 12:10 PM
lebedev.ri requested review of this revision.Aug 24 2021, 12:10 PM
nikic accepted this revision.Aug 29 2021, 12:22 PM

LGTM, I believe your reasoning is correct.

Might make sense to add the test case from D108043 to show that this is an increase in power (because isValidRewrite was a conservative check)? I believe the only relevant part of that test case is that the phi has a loop-invariant input on the backedge and the exit is known to not be taken on the first iteration (thus the value coming from the backedge must be used) -- I don't think load/store forwarding is relevant there.

This revision is now accepted and ready to land.Aug 29 2021, 12:22 PM
This revision was automatically updated to reflect the committed changes.