1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-linux | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
4 ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 | FileCheck %s --check-prefix=X64
5 ; RUN: llc < %s -mtriple=x86_64-nacl | FileCheck %s --check-prefix=X64
7 ; The computation of %t4 should match a single lea, without using actual add instructions.
9 define i32 @test1(i32 %A, i32 %B) {
12 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
13 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
14 ; X86-NEXT: leal -5(%ecx,%eax,4), %eax
19 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
20 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
21 ; X64-NEXT: leal -5(%rsi,%rdi,4), %eax
25 %t4 = add i32 %t3, %t1
29 ; The addlike OR instruction should fold into the LEA.
31 define i64 @test2(i32 %a0, i64 %a1) {
34 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
35 ; X86-NEXT: movl %edx, %eax
36 ; X86-NEXT: andl $2147483640, %eax # imm = 0x7FFFFFF8
37 ; X86-NEXT: shrl $31, %edx
38 ; X86-NEXT: leal 4(%eax,%eax), %eax
39 ; X86-NEXT: addl {{[0-9]+}}(%esp), %eax
40 ; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx
45 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
46 ; X64-NEXT: andl $-8, %edi
47 ; X64-NEXT: leaq 4(%rsi,%rdi,2), %rax
51 %x3 = zext i32 %x2 to i64
53 %x5 = add i64 %a1, %x4