Enable all Hexagon tests.
[oota-llvm.git] / test / CodeGen / X86 / fast-isel-x86-64.ll
index 5762ef331233231c2e8169f43e8135bdd5590434..d8f4663c94e6ebb08310a87281f3bcbed17ab90f 100644 (file)
@@ -14,6 +14,28 @@ define i32 @test1(i32 %i) nounwind ssp {
 ; CHECK: andl  $8, 
 
 
+; rdar://9289512 - The load should fold into the compare.
+define void @test2(i64 %x) nounwind ssp {
+entry:
+  %x.addr = alloca i64, align 8
+  store i64 %x, i64* %x.addr, align 8
+  %tmp = load i64* %x.addr, align 8
+  %cmp = icmp sgt i64 %tmp, 42
+  br i1 %cmp, label %if.then, label %if.end
+
+if.then:                                          ; preds = %entry
+  br label %if.end
+
+if.end:                                           ; preds = %if.then, %entry
+  ret void
+; CHECK: test2:
+; CHECK: movq  %rdi, -8(%rsp)
+; CHECK: cmpq  $42, -8(%rsp)
+}
+
+
+
+
 @G = external global i32
 define i64 @test3() nounwind {
   %A = ptrtoint i32* @G to i64
@@ -60,7 +82,7 @@ entry:
   ret i64 %mul
 
 ; CHECK: test6:
-; CHECK: leaq  (,%rdi,8), %rax
+; CHECK: shlq  $3, %rdi
 }
 
 define i32 @test7(i32 %x) nounwind ssp {
@@ -68,7 +90,7 @@ entry:
   %mul = mul nsw i32 %x, 8
   ret i32 %mul
 ; CHECK: test7:
-; CHECK: leal  (,%rdi,8), %eax
+; CHECK: shll  $3, %edi
 }
 
 
@@ -178,3 +200,88 @@ block2:
   call void (...)* @test16callee(double 1.000000e+00)
   ret void
 }
+
+
+declare void @foo() unnamed_addr ssp align 2
+
+; Verify that we don't fold the load into the compare here.  That would move it
+; w.r.t. the call.
+define i32 @test17(i32 *%P) ssp nounwind {
+entry:
+  %tmp = load i32* %P
+  %cmp = icmp ne i32 %tmp, 5
+  call void @foo()
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:                                          ; preds = %entry
+  ret i32 1
+
+if.else:                                          ; preds = %entry
+  ret i32 2
+; CHECK: test17:
+; CHECK: movl  (%rdi), %eax
+; CHECK: callq _foo
+; CHECK: cmpl  $5, %eax
+; CHECK-NEXT: je 
+}
+
+; Check that 0.0 is materialized using xorps
+define void @test18(float* %p1) {
+  store float 0.0, float* %p1
+  ret void
+; CHECK: test18:
+; CHECK: xorps
+}
+
+; Without any type hints, doubles use the smaller xorps instead of xorpd.
+define void @test19(double* %p1) {
+  store double 0.0, double* %p1
+  ret void
+; CHECK: test19:
+; CHECK: xorps
+}
+
+; Check that we fast-isel sret
+%struct.a = type { i64, i64, i64 }
+define void @test20() nounwind ssp {
+entry:
+  %tmp = alloca %struct.a, align 8
+  call void @test20sret(%struct.a* sret %tmp)
+  ret void
+; CHECK: test20:
+; CHECK: leaq (%rsp), %rdi
+; CHECK: callq _test20sret
+}
+declare void @test20sret(%struct.a* sret)
+
+; Check that -0.0 is not materialized using xor
+define void @test21(double* %p1) {
+  store double -0.0, double* %p1
+  ret void
+; CHECK: test21:
+; CHECK-NOT: xor
+; CHECK: movsd LCPI
+}
+
+; Check that immediate arguments to a function
+; do not cause massive spilling and are used
+; as immediates just before the call.
+define void @test22() nounwind {
+entry:
+  call void @foo22(i32 0)
+  call void @foo22(i32 1)
+  call void @foo22(i32 2)
+  call void @foo22(i32 3)
+  ret void
+; CHECK: test22:
+; CHECK: movl  $0, %edi
+; CHECK: callq _foo22
+; CHECK: movl  $1, %edi
+; CHECK: callq _foo22
+; CHECK: movl  $2, %edi
+; CHECK: callq _foo22
+; CHECK: movl  $3, %edi
+; CHECK: callq _foo22
+}
+
+declare void @foo22(i32)