1 ; RUN: opt < %s -instcombine -globals-aa -licm -S | FileCheck %s
3 ; Make sure -globals-aa ignores dead uses of globals.
5 @a = internal global i32 0, align 4
6 @c = common global i32 0, align 4
8 ; Function Attrs: nounwind
10 ; Make sure the load of @a is hoisted.
11 ; CHECK-LABEL: define i32 @g()
13 ; CHECK-NEXT: load i32, i32* @a, align 4
14 ; CHECK-NEXT: br label %for.cond
18 for.cond: ; preds = %for.inc, %entry
19 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
20 %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
21 %cmp = icmp slt i32 %i.0, 1000
22 br i1 %cmp, label %for.body, label %for.end
24 for.body: ; preds = %for.cond
25 %0 = load i32, i32* @a, align 4
26 %add = add nsw i32 %sum.0, %0
30 for.inc: ; preds = %for.body
31 %inc = add nsw i32 %i.0, 1
34 for.end: ; preds = %for.cond
38 ; Function Attrs: nounwind
39 define internal void @f() {
41 %tobool = icmp ne i32 0, 0
42 br i1 %tobool, label %if.then, label %if.end
44 if.then: ; preds = %entry
45 store i32 ptrtoint (i32* @a to i32), i32* @c, align 4
48 if.end: ; preds = %if.then, %entry
49 %0 = load i32, i32* @c, align 4
50 %inc = add nsw i32 %0, 1
51 store i32 %inc, i32* @c, align 4