[llvm] r358100 - [InstCombine] Handle ssubo always overflow
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 09:32:16 PDT 2019
Author: nikic
Date: Wed Apr 10 09:32:15 2019
New Revision: 358100
URL: http://llvm.org/viewvc/llvm-project?rev=358100&view=rev
Log:
[InstCombine] Handle ssubo always overflow
Following D60483 and D60497, this adds support for AlwaysOverflows
handling for ssubo. This is the last case we can handle right now.
Differential Revision: https://reviews.llvm.org/D60518
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=358100&r1=358099&r2=358100&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Apr 10 09:32:15 2019
@@ -3997,15 +3997,15 @@ bool InstCombiner::OptimizeOverflowCheck
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)
return SetResult(Builder.CreateNSWSub(LHS, RHS), Builder.getFalse(),
true);
}
+
+ if (OR == OverflowResult::AlwaysOverflows)
+ return SetResult(Builder.CreateSub(LHS, RHS), Builder.getTrue(), true);
break;
}
Modified: llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/with_overflow.ll?rev=358100&r1=358099&r2=358100&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/with_overflow.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/with_overflow.ll Wed Apr 10 09:32:15 2019
@@ -582,8 +582,9 @@ define { i8, i1 } @ssub_always_overflow(
; CHECK-LABEL: @ssub_always_overflow(
; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], 29
; CHECK-NEXT: [[Y:%.*]] = select i1 [[C]], i8 [[X]], i8 29
-; CHECK-NEXT: [[A:%.*]] = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 -100, i8 [[Y]])
-; CHECK-NEXT: ret { i8, i1 } [[A]]
+; CHECK-NEXT: [[A:%.*]] = sub nuw i8 -100, [[Y]]
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i8, i1 } { i8 undef, i1 true }, i8 [[A]], 0
+; CHECK-NEXT: ret { i8, i1 } [[TMP1]]
;
%c = icmp sgt i8 %x, 29
%y = select i1 %c, i8 %x, i8 29
More information about the llvm-commits
mailing list