blob: 52b1e8564338e5075470e8dc9dd02b357ef00cd0 [file] [log] [blame]
Preston Gurd5b507012012-07-19 18:53:21 +00001; 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
Evan Cheng373d50a2008-09-04 06:18:33 +00003
4@src = external global i32
5
Chris Lattnerbeac75d2010-09-05 02:18:34 +00006; rdar://6653118
Evan Cheng373d50a2008-09-04 06:18:33 +00007define i32 @loadgv() nounwind {
8entry:
9 %0 = load i32* @src, align 4
10 %1 = load i32* @src, align 4
11 %2 = add i32 %0, %1
Evan Cheng59fbc802008-09-09 01:26:59 +000012 store i32 %2, i32* @src
Evan Cheng373d50a2008-09-04 06:18:33 +000013 ret i32 %2
Chris Lattnerbeac75d2010-09-05 02:18:34 +000014; This should fold one of the loads into the add.
15; CHECK: 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
Preston Gurd5b507012012-07-19 18:53:21 +000022; 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
Evan Cheng373d50a2008-09-04 06:18:33 +000029}
Evan Cheng59fbc802008-09-09 01:26:59 +000030
31%stuff = type { i32 (...)** }
32@LotsStuff = external constant [4 x i32 (...)*]
33
34define void @t(%stuff* %this) nounwind {
35entry:
36 store i32 (...)** getelementptr ([4 x i32 (...)*]* @LotsStuff, i32 0, i32 2), i32 (...)*** null, align 4
37 ret void
Chris Lattnerbeac75d2010-09-05 02:18:34 +000038; CHECK: _t:
39; CHECK: movl $0, %eax
40; CHECK: movl L_LotsStuff$non_lazy_ptr, %ecx
41
Preston Gurd5b507012012-07-19 18:53:21 +000042; ATOM: _t:
43; ATOM: movl L_LotsStuff$non_lazy_ptr, %ecx
44; ATOM: movl $0, %eax
45
Evan Cheng59fbc802008-09-09 01:26:59 +000046}