[PATCH] D60497: [InstCombine] Handle saddo always overflow
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 00:15:33 PDT 2019
nikic created this revision.
nikic added reviewers: lebedev.ri, spatel.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Followup to D60483 <https://reviews.llvm.org/D60483>: Handle always overflow condition for saddo.
Repository:
rL LLVM
https://reviews.llvm.org/D60497
Files:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/with_overflow.ll
Index: llvm/test/Transforms/InstCombine/with_overflow.ll
===================================================================
--- llvm/test/Transforms/InstCombine/with_overflow.ll
+++ llvm/test/Transforms/InstCombine/with_overflow.ll
@@ -568,8 +568,9 @@
; 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
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3973,15 +3973,15 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60497.194453.patch
Type: text/x-patch
Size: 1750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190410/4cf52a92/attachment.bin>
More information about the llvm-commits
mailing list