[InstCombine] foldUnsignedUnderflowCheck(): handle last few cases (PR43251)
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 18 Sep 2019 20:10:07 +0000 (20:10 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 18 Sep 2019 20:10:07 +0000 (20:10 +0000)
commitb646dd92c2385d31104057e8ff6f651b28c931b6
tree18ff0f8da03c25350b990099be6419ebac30f90b
parent366ab0d086a457b085e3c9ba1c987d5499079cd6
[InstCombine] foldUnsignedUnderflowCheck(): handle last few cases (PR43251)

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)

With this, i see no other missing folds for
https://bugs.llvm.org/show_bug.cgi?id=43251

Reviewers: spatel, nikic, xbolva00

Reviewed By: spatel

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67412

llvm-svn: 372257
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/result-of-usub-is-non-zero-and-no-overflow.ll