CodeGen peephole: fold redundant phys reg copies
[oota-llvm.git] / test / CodeGen / X86 / add-of-carry.ll
index 4c2257494d2a44d9264a9f7a08cfd103ef0cdcad..44b587af3aaad1e3a5aa3da24d467d21c9558980 100644 (file)
@@ -1,14 +1,29 @@
 ; 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:       sbbl    %ecx, %ecx
-; CHECK-NOT: addl
-; CHECK: subl  %ecx, %eax
+; CHECK-LABEL: test1:
+; CHECK: movl
+; CHECK-NEXT: addl
+; CHECK-NEXT: adcl $0
+; CHECK-NEXT: ret
   %add4 = add i32 %x, %sum
   %cmp = icmp ult i32 %add4, %x
   %inc = zext i1 %cmp to i32
   %z.0 = add i32 %add4, %inc
   ret i32 %z.0
 }
+
+; <rdar://problem/12579915>
+define i32 @test2(i32 %x, i32 %y, i32 %res) nounwind uwtable readnone ssp {
+entry:
+  %cmp = icmp ugt i32 %x, %y
+  %dec = sext i1 %cmp to i32
+  %dec.res = add nsw i32 %dec, %res
+  ret i32 %dec.res
+; CHECK-LABEL: test2:
+; CHECK: cmpl
+; CHECK: sbbl
+; CHECK: ret
+}