1 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=generic | FileCheck %s
2 ; RUN: llc < %s -fast-isel -mtriple=i386-apple-darwin -mcpu=atom | FileCheck -check-prefix=ATOM %s
3 ; RUN: llc < %s -fast-isel -fast-isel-abort=3 -mtriple=x86_64 | FileCheck -check-prefix=ELF64 %s
5 @src = external dso_preemptable global i32
8 define i32 @loadgv() nounwind {
10 %0 = load i32, ptr @src, align 4
11 %1 = load i32, ptr @src, align 4
13 store i32 %2, ptr @src
15 ; This should fold one of the loads into the add.
16 ; CHECK-LABEL: loadgv:
17 ; CHECK: movl L_src$non_lazy_ptr, %eax
18 ; CHECK: movl (%eax), %eax
19 ; CHECK: movl L_src$non_lazy_ptr, %ecx
20 ; CHECK: addl (%ecx), %eax
21 ; CHECK: movl L_src$non_lazy_ptr, %ecx
22 ; CHECK: movl %eax, (%ecx)
26 ; ATOM: movl L_src$non_lazy_ptr, %eax
27 ; ATOM: movl (%eax), %eax
28 ; ATOM: movl L_src$non_lazy_ptr, %ecx
29 ; ATOM: addl (%ecx), %eax
30 ; ATOM: movl L_src$non_lazy_ptr, %ecx
31 ; ATOM: movl %eax, (%ecx)
34 ;; dso_preemptable src is loaded via GOT indirection.
35 ; ELF64-LABEL: loadgv:
36 ; ELF64: movq src@GOTPCREL(%rip), %rax
37 ; ELF64-NEXT: movl (%rax), %eax
38 ; ELF64-NEXT: movq src@GOTPCREL(%rip), %rcx
39 ; ELF64-NEXT: addl (%rcx), %eax
40 ; ELF64-NEXT: movq src@GOTPCREL(%rip), %rcx
41 ; ELF64-NEXT: movl %eax, (%rcx)
47 @LotsStuff = external constant [4 x ptr]
49 define void @t(ptr %this) nounwind {
51 store ptr getelementptr ([4 x ptr], ptr @LotsStuff, i32 0, i32 2), ptr null, align 4
54 ; CHECK: xorl %eax, %eax
55 ; CHECK: movl L_LotsStuff$non_lazy_ptr, %ecx
58 ; ATOM: movl L_LotsStuff$non_lazy_ptr, %e{{..}}
59 ; ATOM: xorl %e{{..}}, %e{{..}}