diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-28 18:08:31 +0000 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-28 18:08:31 +0000 |
| commit | 332c10056227d5da5557f50e8c64dc8814ca56f0 (patch) | |
| tree | 4ca1abc675a10809ee43eefec87544139d77c3ef /llvm/lib/Transforms/InstCombine | |
| parent | 2fb0a820df9c9884b9f42efdd0919b309e2b1204 (diff) | |
| download | bcm5719-llvm-332c10056227d5da5557f50e8c64dc8814ca56f0.tar.gz bcm5719-llvm-332c10056227d5da5557f50e8c64dc8814ca56f0.zip | |
[ValueTracking][ConstantRange] Distinguish low/high always overflow
In order to fold an always overflowing signed saturating add/sub,
we need to know in which direction the always overflow occurs.
This patch splits up AlwaysOverflows into AlwaysOverflowsLow and
AlwaysOverflowsHigh to pass through this information (but it is
not used yet).
Differential Revision: https://reviews.llvm.org/D62463
llvm-svn: 361858
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index e2813f9d9d4..a18043ef33f 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2064,7 +2064,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { OR = computeOverflowForUnsignedAdd(Arg0, Arg1, II); if (OR == OverflowResult::NeverOverflows) return BinaryOperator::CreateNUWAdd(Arg0, Arg1); - if (OR == OverflowResult::AlwaysOverflows) + if (OR == OverflowResult::AlwaysOverflowsHigh) return replaceInstUsesWith(*II, ConstantInt::getAllOnesValue(II->getType())); break; @@ -2072,7 +2072,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { OR = computeOverflowForUnsignedSub(Arg0, Arg1, II); if (OR == OverflowResult::NeverOverflows) return BinaryOperator::CreateNUWSub(Arg0, Arg1); - if (OR == OverflowResult::AlwaysOverflows) + if (OR == OverflowResult::AlwaysOverflowsLow) return replaceInstUsesWith(*II, ConstantInt::getNullValue(II->getType())); break; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index ab2da177d7b..b3eb75ea8a8 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3993,7 +3993,8 @@ bool InstCombiner::OptimizeOverflowCheck( switch (computeOverflow(BinaryOp, IsSigned, LHS, RHS, &OrigI)) { case OverflowResult::MayOverflow: return false; - case OverflowResult::AlwaysOverflows: + case OverflowResult::AlwaysOverflowsLow: + case OverflowResult::AlwaysOverflowsHigh: Result = Builder.CreateBinOp(BinaryOp, LHS, RHS); Result->takeName(&OrigI); Overflow = Builder.getTrue(); |

