xref: /llvm-project/llvm/test/CodeGen/X86/lea-opt-cse1.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s -check-prefix=X64
3; RUN: llc < %s -mtriple=i686-unknown   | FileCheck %s -check-prefix=X86
4
5%struct.SA = type { i32 , i32  , i32 , i32 ,i32 }
6
7define void @test_func(ptr nocapture %ctx, i32 %n) local_unnamed_addr {
8; X64-LABEL: test_func:
9; X64:       # %bb.0: # %entry
10; X64-NEXT:    movl (%rdi), %eax
11; X64-NEXT:    movl 16(%rdi), %ecx
12; X64-NEXT:    leal (%rax,%rcx), %edx
13; X64-NEXT:    leal 1(%rax,%rcx), %eax
14; X64-NEXT:    movl %eax, 12(%rdi)
15; X64-NEXT:    leal 1(%rcx,%rdx), %eax
16; X64-NEXT:    movl %eax, 16(%rdi)
17; X64-NEXT:    retq
18;
19; X86-LABEL: test_func:
20; X86:       # %bb.0: # %entry
21; X86-NEXT:    pushl %esi
22; X86-NEXT:    .cfi_def_cfa_offset 8
23; X86-NEXT:    .cfi_offset %esi, -8
24; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
25; X86-NEXT:    movl (%eax), %ecx
26; X86-NEXT:    movl 16(%eax), %edx
27; X86-NEXT:    leal 1(%ecx,%edx), %esi
28; X86-NEXT:    addl %edx, %ecx
29; X86-NEXT:    movl %esi, 12(%eax)
30; X86-NEXT:    leal 1(%edx,%ecx), %ecx
31; X86-NEXT:    movl %ecx, 16(%eax)
32; X86-NEXT:    popl %esi
33; X86-NEXT:    .cfi_def_cfa_offset 4
34; X86-NEXT:    retl
35 entry:
36   %0 = load i32, ptr %ctx, align 8
37   %h3 = getelementptr inbounds %struct.SA, ptr %ctx, i64 0, i32 3
38   %h4 = getelementptr inbounds %struct.SA, ptr %ctx, i64 0, i32 4
39   %1 = load i32, ptr %h4, align 8
40   %add = add i32 %0, 1
41   %add4 = add i32 %add, %1
42   store i32 %add4, ptr %h3, align 4
43   %add29 = add i32 %add4 , %1
44   store i32 %add29, ptr %h4, align 8
45   ret void
46}
47