[x32] Fix FrameIndex check in SelectLEA64_32Addr
[oota-llvm.git] / test / CodeGen / X86 / twoaddr-lea.ll
index a245ed7caa8417d9b2dbaa3c3fd0d8fd316bd900..b5ca0275d8d698308a963cc40eba3f55d95cc6ea 100644 (file)
@@ -5,20 +5,43 @@
 ;; allocator turns the shift into an LEA.  This also occurs for ADD.
 
 ; Check that the shift gets turned into an LEA.
-; RUN: llc < %s -march=x86 -x86-asm-syntax=intel | \
-; RUN:   not grep {mov E.X, E.X}
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin | FileCheck %s
 
-@G = external global i32                ; <i32*> [#uses=3]
+@G = external global i32
 
-define i32 @test1(i32 %X, i32 %Y) {
-        %Z = add i32 %X, %Y             ; <i32> [#uses=1]
-        volatile store i32 %Y, i32* @G
-        volatile store i32 %Z, i32* @G
+define i32 @test1(i32 %X) nounwind {
+; CHECK-LABEL: test1:
+; CHECK-NOT: mov
+; CHECK: leal 1(%rdi)
+        %Z = add i32 %X, 1
+        store volatile i32 %Z, i32* @G
         ret i32 %X
 }
 
-define i32 @test2(i32 %X) {
-        %Z = add i32 %X, 1              ; <i32> [#uses=1]
-        volatile store i32 %Z, i32* @G
-        ret i32 %X
+; rdar://8977508
+; The second add should not be transformed to leal nor should it be
+; commutted (which would require inserting a copy).
+define i32 @test2(i32 inreg %a, i32 inreg %b, i32 %c, i32 %d) nounwind {
+entry:
+; CHECK-LABEL: test2:
+; CHECK: leal
+; CHECK-NOT: leal
+; CHECK-NOT: mov
+; CHECK-NEXT: addl
+; CHECK-NEXT: ret
+ %add = add i32 %b, %a
+ %add3 = add i32 %add, %c
+ %add5 = add i32 %add3, %d
+ ret i32 %add5
+}
+
+; rdar://9002648
+define i64 @test3(i64 %x) nounwind readnone ssp {
+entry:
+; CHECK-LABEL: test3:
+; CHECK: leaq (%rdi,%rdi), %rax
+; CHECK-NOT: addq
+; CHECK-NEXT: ret
+  %0 = shl i64 %x, 1
+  ret i64 %0
 }