diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-04-10 07:10:53 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-04-10 07:10:53 +0000 |
commit | 09020ec2a7199fca2835e6dbbac9d89f9222a843 (patch) | |
tree | 4f88088ed07b425ff6b33645a587a5d4efd6efd8 /llvm/lib | |
parent | 596cbeb7058b98518952612069e2bb0b13863ef8 (diff) | |
download | bcm5719-llvm-09020ec2a7199fca2835e6dbbac9d89f9222a843.tar.gz bcm5719-llvm-09020ec2a7199fca2835e6dbbac9d89f9222a843.zip |
[InstCombine] Handle usubo always overflow
Check AlwaysOverflow condition for usubo. The implementation is the
same as the existing handling for uaddo and umulo. Handling for saddo
and ssubo will follow (smulo doesn't have the necessary ValueTracking
support).
Differential Revision: https://reviews.llvm.org/D60483
llvm-svn: 358052
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index e274d7efddb..7ec75358f7b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3997,6 +3997,9 @@ bool InstCombiner::OptimizeOverflowCheck(OverflowCheckFlavor OCF, Value *LHS, if (OR == OverflowResult::NeverOverflows) return SetResult(Builder.CreateNUWSub(LHS, RHS), Builder.getFalse(), true); + + if (OR == OverflowResult::AlwaysOverflows) + return SetResult(Builder.CreateSub(LHS, RHS), Builder.getTrue(), true); } else { OR = computeOverflowForSignedSub(LHS, RHS, &OrigI); if (OR == OverflowResult::NeverOverflows) |