This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] simplifyUnsignedRangeCheck(): handle more cases (PR43251)
ClosedPublic

Authored by lebedev.ri on Sep 10 2019, 12:06 PM.

Details

Summary

I don't have a direct motivational case for this,
but it would be good to have this for completeness/symmetry.

This pattern is basically the motivational pattern from
https://bugs.llvm.org/show_bug.cgi?id=43251
but with different predicate that requires that the offset is non-zero.

The completeness bit comes from the fact that a similar pattern (offset != zero)
will be needed for https://bugs.llvm.org/show_bug.cgi?id=43259,
so it'd seem to be good to not overlook very similar patterns..

Proofs: https://rise4fun.com/Alive/21b

Also, there is something odd with isKnownNonZero(), if the non-zero
knowledge was specified as an assumption, it didn't pick it up (PR43267)

Diff Detail

Event Timeline

lebedev.ri created this revision.Sep 10 2019, 12:06 PM
lebedev.ri edited the summary of this revision. (Show Details)Sep 10 2019, 1:12 PM
spatel added inline comments.Sep 11 2019, 8:11 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1774–1775

Can the diffs to thread the full SimplifyQuery through the calls be done as a preliminary step?
I'm not sure how to expose a diff in a test, but I'd think it's not quite 'NFC', so it should be an independent change.

lebedev.ri added inline comments.Sep 11 2019, 8:16 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1774–1775

I actually messed up in D67332, i didn't actually mean to *only* pass DL, it just kind-of fell through cracks :/
So passing SimplifyQuery is actually *intended* as NFC, but then i'm trying to balance
between having too much patches, and having too big patches.
Let me see if i can come up with a test.

spatel added inline comments.Sep 11 2019, 8:24 AM
llvm/lib/Analysis/InstructionSimplify.cpp
1774–1775

I'm fine with just changing the code by inspection as a preliminary to this patch; it's clearly an improvement.

lebedev.ri marked 4 inline comments as done.Sep 11 2019, 8:31 AM
lebedev.ri added inline comments.
llvm/lib/Analysis/InstructionSimplify.cpp
1774–1775

Done in rL371630, will rebase in a sec.

lebedev.ri marked an inline comment as done.

Rebased to only contain the actual change itself and none of the SimplifyQuery threading-in.

spatel accepted this revision.Sep 11 2019, 12:54 PM

LGTM

This revision is now accepted and ready to land.Sep 11 2019, 12:54 PM

LGTM

Thank you for the review.

This revision was automatically updated to reflect the committed changes.