[llvm] r358095 - [InstCombine] Handle saddo always overflow
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 09:18:02 PDT 2019
Author: nikic
Date: Wed Apr 10 09:18:01 2019
New Revision: 358095
URL: http://llvm.org/viewvc/llvm-project?rev=358095&view=rev
Log:
[InstCombine] Handle saddo always overflow
Followup to D60483: Handle AlwaysOverflow conditions for saddo as
well.
Differential Revision: https://reviews.llvm.org/D60497
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=358095&r1=358094&r2=358095&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Wed Apr 10 09:18:01 2019
@@ -3973,15 +3973,15 @@ bool InstCombiner::OptimizeOverflowCheck
if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNUWAdd(LHS, RHS), Builder.getFalse(),
true);
-
- if (OR == OverflowResult::AlwaysOverflows)
- return SetResult(Builder.CreateAdd(LHS, RHS), Builder.getTrue(), true);
} else {
OR = computeOverflowForSignedAdd(LHS, RHS, &OrigI);
if (OR == OverflowResult::NeverOverflows)
return SetResult(Builder.CreateNSWAdd(LHS, RHS), Builder.getFalse(),
true);
}
+
+ if (OR == OverflowResult::AlwaysOverflows)
+ return SetResult(Builder.CreateAdd(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=358095&r1=358094&r2=358095&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/with_overflow.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/with_overflow.ll Wed Apr 10 09:18:01 2019
@@ -568,8 +568,9 @@ define { i8, i1 } @sadd_always_overflow(
; CHECK-LABEL: @sadd_always_overflow(
; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[X:%.*]], 100
; CHECK-NEXT: [[Y:%.*]] = select i1 [[C]], i8 [[X]], i8 100
-; CHECK-NEXT: [[A:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[Y]], i8 28)
-; CHECK-NEXT: ret { i8, i1 } [[A]]
+; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[Y]], 28
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i8, i1 } { i8 undef, i1 true }, i8 [[A]], 0
+; CHECK-NEXT: ret { i8, i1 } [[TMP1]]
;
%c = icmp sgt i8 %x, 100
%y = select i1 %c, i8 %x, i8 100
More information about the llvm-commits
mailing list