[IRCE] Only check for NSW on equality predicates
ClosedPublic

Authored by samparker on Fri, Apr 13, 4:33 AM.

Details

Summary

After investigation discussed in D45439, it would seem that the nsw flag restriction is unnecessary in most cases. So the IsInductionVar lambda has been removed, the functionality extracted, and now only require nsw when using eq/ne predicates.

Diff Detail

Repository
rL LLVM
samparker created this revision.Fri, Apr 13, 4:33 AM
mkazantsev added inline comments.Mon, Apr 16, 1:47 AM
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
933 ↗(On Diff #142378)

How about non-constant steps?

For me it looks fine, but please let me run some tests with this patch. I don't see obvious problem, and if they aren't revealed by this testing, I'll give my approval. It will take few hours.

lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
933 ↗(On Diff #142378)

Never mind, it's checked above. Could have been a dyn_cast on line 923.

mkazantsev added inline comments.Mon, Apr 16, 1:59 AM
test/Transforms/IRCE/stride_more_than_1.ll
221 ↗(On Diff #142378)

Will you please add a check that the postloop is generated? It looks like we should have one here, am I correct?

mkazantsev added inline comments.Mon, Apr 16, 2:05 AM
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
923 ↗(On Diff #142378)

Please do affinity check first and take StepRecurrence only if it passes, it will save you some compile time on non-affine phis. Also can be dyn_cast.

mkazantsev accepted this revision.Mon, Apr 16, 6:36 AM

My tasting has passed. LGTM with minor changes (comments inline).

This revision is now accepted and ready to land.Mon, Apr 16, 6:36 AM
samparker marked 2 inline comments as done.Wed, Apr 18, 6:52 AM
samparker added inline comments.
test/Transforms/IRCE/stride_more_than_1.ll
221 ↗(On Diff #142378)

sure. you're correct.

Closed by commit rL330256: [IRCE] Only check for NSW on equality predicates (authored by sam_parker, committed by ). · Explain WhyWed, Apr 18, 6:53 AM
This revision was automatically updated to reflect the committed changes.