Instruction scheduling itinerary for Intel Atom.
[oota-llvm.git] / test / CodeGen / X86 / twoaddr-lea.ll
1 ;; X's live range extends beyond the shift, so the register allocator
2 ;; cannot coalesce it with Y.  Because of this, a copy needs to be
3 ;; emitted before the shift to save the register value before it is
4 ;; clobbered.  However, this copy is not needed if the register
5 ;; allocator turns the shift into an LEA.  This also occurs for ADD.
6
7 ; Check that the shift gets turned into an LEA.
8 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin | FileCheck %s
9
10 @G = external global i32
11
12 define i32 @test1(i32 %X) nounwind {
13 ; CHECK: test1:
14 ; CHECK-NOT: mov
15 ; CHECK: leal 1(%rdi)
16         %Z = add i32 %X, 1
17         store volatile i32 %Z, i32* @G
18         ret i32 %X
19 }
20
21 ; rdar://8977508
22 ; The second add should not be transformed to leal nor should it be
23 ; commutted (which would require inserting a copy).
24 define i32 @test2(i32 inreg %a, i32 inreg %b, i32 %c, i32 %d) nounwind {
25 entry:
26 ; CHECK: test2:
27 ; CHECK: leal
28 ; CHECK-NOT: leal
29 ; CHECK-NOT: mov
30 ; CHECK-NEXT: addl
31 ; CHECK-NEXT: ret
32  %add = add i32 %b, %a
33  %add3 = add i32 %add, %c
34  %add5 = add i32 %add3, %d
35  ret i32 %add5
36 }
37
38 ; rdar://9002648
39 define i64 @test3(i64 %x) nounwind readnone ssp {
40 entry:
41 ; CHECK: test3:
42 ; CHECK: leaq (%rdi,%rdi), %rax
43 ; CHECK-NOT: addq
44 ; CHECK-NEXT: ret
45   %0 = shl i64 %x, 1
46   ret i64 %0
47 }