diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-25 22:59:59 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-25 22:59:59 +0000 |
commit | a2fa03af3ab961e718d295c6dbdbde3ac4ae8dd8 (patch) | |
tree | e097a7fb6887091ed4a1bfa1f379dab3de4f0d0f /llvm/lib/Transforms | |
parent | ca524621d14cd35c4cc226e53ccf3be403bdfc37 (diff) | |
download | bcm5719-llvm-a2fa03af3ab961e718d295c6dbdbde3ac4ae8dd8.tar.gz bcm5719-llvm-a2fa03af3ab961e718d295c6dbdbde3ac4ae8dd8.zip |
[InstCombine] foldUnsignedUnderflowCheck(): one last pattern with 'sub' (PR43251)
https://rise4fun.com/Alive/0j9
llvm-svn: 372930
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 6252e5d15a1..db5095b6fea 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1128,6 +1128,16 @@ static Value *foldUnsignedUnderflowCheck(ICmpInst *ZeroICmp, EqPred == ICmpInst::ICMP_EQ && !IsAnd) return Builder.CreateICmpULE(Base, Offset); + // Base <= Offset && (Base - Offset) != 0 --> Base < Offset + if (UnsignedPred == ICmpInst::ICMP_ULE && EqPred == ICmpInst::ICMP_NE && + IsAnd) + return Builder.CreateICmpULT(Base, Offset); + + // Base > Offset || (Base - Offset) == 0 --> Base >= Offset + if (UnsignedPred == ICmpInst::ICMP_UGT && EqPred == ICmpInst::ICMP_EQ && + !IsAnd) + return Builder.CreateICmpUGE(Base, Offset); + return nullptr; } |