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 4 @src = external global i32 5 6 ; rdar://6653118 7 define i32 @loadgv() nounwind { 8 entry: 9 %0 = load i32* @src, align 4 10 %1 = load i32* @src, align 4 11 %2 = add i32 %0, %1 12 store i32 %2, i32* @src 13 ret i32 %2 14 ; This should fold one of the loads into the add. 15 ; CHECK-LABEL: loadgv: 16 ; CHECK: movl L_src$non_lazy_ptr, %ecx 17 ; CHECK: movl (%ecx), %eax 18 ; CHECK: addl (%ecx), %eax 19 ; CHECK: movl %eax, (%ecx) 20 ; CHECK: ret 21 22 ; ATOM: loadgv: 23 ; ATOM: movl L_src$non_lazy_ptr, %ecx 24 ; ATOM: movl (%ecx), %eax 25 ; ATOM: addl (%ecx), %eax 26 ; ATOM: movl %eax, (%ecx) 27 ; ATOM: ret 28 29 } 30 31 %stuff = type { i32 (...)** } 32 @LotsStuff = external constant [4 x i32 (...)*] 33 34 define void @t(%stuff* %this) nounwind { 35 entry: 36 store i32 (...)** getelementptr ([4 x i32 (...)*]* @LotsStuff, i32 0, i32 2), i32 (...)*** null, align 4 37 ret void 38 ; CHECK: _t: 39 ; CHECK: movl $0, %eax 40 ; CHECK: movl L_LotsStuff$non_lazy_ptr, %ecx 41 42 ; ATOM: _t: 43 ; ATOM: movl L_LotsStuff$non_lazy_ptr, %e{{..}} 44 ; ATOM: movl $0, %e{{..}} 45 46 } 47