summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/add-of-carry.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 22:08:31 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 22:08:31 +0000
commitc19d1c3ba2b216f0f91d71cf6fc2e983fc995854 (patch)
treebac5a92aeaf2d30963e52aa20486d19a0fef1b06 /test/CodeGen/X86/add-of-carry.ll
parent22d67cf6ac84c06867681a2fe72f78d5d2b9444d (diff)
downloadllvm-c19d1c3ba2b216f0f91d71cf6fc2e983fc995854.tar.gz
llvm-c19d1c3ba2b216f0f91d71cf6fc2e983fc995854.tar.bz2
llvm-c19d1c3ba2b216f0f91d71cf6fc2e983fc995854.tar.xz
improve the setcc -> setcc_carry optimization to happen more
consistently by moving it out of lowering into dag combine. Add some missing patterns for matching away extended versions of setcc_c. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/add-of-carry.ll')
-rw-r--r--test/CodeGen/X86/add-of-carry.ll22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/CodeGen/X86/add-of-carry.ll b/test/CodeGen/X86/add-of-carry.ll
index 4c2257494d..f924ec8132 100644
--- a/test/CodeGen/X86/add-of-carry.ll
+++ b/test/CodeGen/X86/add-of-carry.ll
@@ -1,8 +1,9 @@
; RUN: llc < %s -march=x86 | FileCheck %s
; <rdar://problem/8449754>
-define i32 @add32carry(i32 %sum, i32 %x) nounwind readnone ssp {
+define i32 @test1(i32 %sum, i32 %x) nounwind readnone ssp {
entry:
+; CHECK: test1:
; CHECK: sbbl %ecx, %ecx
; CHECK-NOT: addl
; CHECK: subl %ecx, %eax
@@ -12,3 +13,22 @@ entry:
%z.0 = add i32 %add4, %inc
ret i32 %z.0
}
+
+; Instcombine transforms test1 into test2:
+; CHECK: test2:
+; CHECK: movl
+; CHECK-NEXT: addl
+; CHECK-NEXT: sbbl
+; CHECK-NEXT: subl
+; CHECK-NEXT: ret
+define i32 @test2(i32 %sum, i32 %x) nounwind readnone ssp {
+entry:
+ %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %sum)
+ %0 = extractvalue { i32, i1 } %uadd, 0
+ %cmp = extractvalue { i32, i1 } %uadd, 1
+ %inc = zext i1 %cmp to i32
+ %z.0 = add i32 %0, %inc
+ ret i32 %z.0
+}
+
+declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone