Instruction scheduling itinerary for Intel Atom.
[oota-llvm.git] / test / CodeGen / X86 / add.ll
index 3991a6849f3ed3d1d2f5601eacc86fa585173b88..8e871f4aeb4df802f34f9c7118266c47ee66ff31 100644 (file)
@@ -1,5 +1,8 @@
-; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X32
-; RUN: llc < %s -march=x86-64 | FileCheck %s -check-prefix=X64
+; RUN: llc < %s -mcpu=generic -march=x86 | FileCheck %s -check-prefix=X32
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -join-physregs | FileCheck %s -check-prefix=X64
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-win32 -join-physregs | FileCheck %s -check-prefix=X64
+
+; Some of these tests depend on -join-physregs to commute instructions.
 
 ; The immediate can be encoded in a smaller way if the
 ; instruction is a sub instead of an add.
@@ -43,7 +46,7 @@ overflow:
 ; X32-NEXT: jo
 
 ; X64:        test4:
-; X64:          addl   %esi, %edi
+; X64:          addl   %e[[A1:si|dx]], %e[[A0:di|cx]]
 ; X64-NEXT:    jo
 }
 
@@ -66,7 +69,7 @@ carry:
 ; X32-NEXT: jb
 
 ; X64:        test5:
-; X64:          addl   %esi, %edi
+; X64:          addl   %e[[A1]], %e[[A0]]
 ; X64-NEXT:    jb
 }
 
@@ -87,8 +90,63 @@ define i64 @test6(i64 %A, i32 %B) nounwind {
 ; X32-NEXT: ret
         
 ; X64: test6:
-; X64: shlq    $32, %rsi
-; X64: leaq    (%rsi,%rdi), %rax
+; X64: shlq    $32, %r[[A1]]
+; X64: leaq    (%r[[A1]],%r[[A0]]), %rax
 ; X64: ret
 }
 
+define {i32, i1} @test7(i32 %v1, i32 %v2) nounwind {
+   %t = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %v1, i32 %v2)
+   ret {i32, i1} %t
+}
+
+; X64: test7:
+; X64: addl %e[[A1]], %eax
+; X64-NEXT: setb %dl
+; X64-NEXT: ret
+
+; PR5443
+define {i64, i1} @test8(i64 %left, i64 %right) nounwind {
+entry:
+    %extleft = zext i64 %left to i65
+    %extright = zext i64 %right to i65
+    %sum = add i65 %extleft, %extright
+    %res.0 = trunc i65 %sum to i64
+    %overflow = and i65 %sum, -18446744073709551616
+    %res.1 = icmp ne i65 %overflow, 0
+    %final0 = insertvalue {i64, i1} undef, i64 %res.0, 0
+    %final1 = insertvalue {i64, i1} %final0, i1 %res.1, 1
+    ret {i64, i1} %final1
+}
+
+; X64: test8:
+; X64: addq
+; X64-NEXT: sbbq
+; X64-NEXT: testb
+
+define i32 @test9(i32 %x, i32 %y) nounwind readnone {
+  %cmp = icmp eq i32 %x, 10
+  %sub = sext i1 %cmp to i32
+  %cond = add i32 %sub, %y
+  ret i32 %cond
+; X64: test9:
+; X64: cmpl $10
+; X64: sete
+; X64: subl
+; X64: ret
+}
+
+define i1 @test10(i32 %x) nounwind {
+entry:
+  %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %x, i32 1)
+  %obit = extractvalue {i32, i1} %t, 1
+  ret i1 %obit
+
+; X32: test10:
+; X32: incl
+; X32-NEXT: seto
+
+; X64: test10:
+; X64: incl
+; X64-NEXT: seto
+}