diff options
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) |