[PATCH] D60518: [InstCombine] Handle ssubo always overflow
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 09:31:32 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358100: [InstCombine] Handle ssubo always overflow (authored by nikic, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60518?vs=194531&id=194536#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60518/new/
https://reviews.llvm.org/D60518
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
Index: llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
+++ llvm/trunk/test/Transforms/InstCombine/with_overflow.ll
@@ -582,8 +582,9 @@
; 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
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3997,15 +3997,15 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60518.194536.patch
Type: text/x-patch
Size: 1786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190410/0883bc4d/attachment.bin>
More information about the llvm-commits
mailing list