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-LABEL: 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-LABEL: test2: 27 ; CHECK: leal 28 ; CHECK-NEXT: addl 29 ; CHECK-NEXT: addl 30 ; CHECK-NEXT: ret 31 %add = add i32 %b, %a 32 %add3 = add i32 %add, %c 33 %add5 = add i32 %add3, %d 34 ret i32 %add5 35 } 36 37 ; rdar://9002648 38 define i64 @test3(i64 %x) nounwind readnone ssp { 39 entry: 40 ; CHECK-LABEL: test3: 41 ; CHECK: leaq (%rdi,%rdi), %rax 42 ; CHECK-NOT: addq 43 ; CHECK-NEXT: ret 44 %0 = shl i64 %x, 1 45 ret i64 %0 46 } 47