1; RUN: opt < %s -instcombine -globals-aa -licm -enable-new-pm=0 -S | FileCheck %s 2; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes='function(instcombine),require<globals-aa>,function(invalidate<aa>,loop(licm))' -S | FileCheck %s 3 4; Make sure -globals-aa ignores dead uses of globals. 5 6@a = internal global i32 0, align 4 7@c = common global i32 0, align 4 8 9; Function Attrs: nounwind 10define i32 @g() { 11; Make sure the load of @a is hoisted. 12; CHECK-LABEL: define i32 @g() 13; CHECK: entry: 14; CHECK-NEXT: load i32, i32* @a, align 4 15; CHECK-NEXT: br label %for.cond 16entry: 17 br label %for.cond 18 19for.cond: ; preds = %for.inc, %entry 20 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] 21 %sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] 22 %cmp = icmp slt i32 %i.0, 1000 23 br i1 %cmp, label %for.body, label %for.end 24 25for.body: ; preds = %for.cond 26 %0 = load i32, i32* @a, align 4 27 %add = add nsw i32 %sum.0, %0 28 call void @f() 29 br label %for.inc 30 31for.inc: ; preds = %for.body 32 %inc = add nsw i32 %i.0, 1 33 br label %for.cond 34 35for.end: ; preds = %for.cond 36 ret i32 %sum.0 37} 38 39; Function Attrs: nounwind 40define internal void @f() { 41entry: 42 %tobool = icmp ne i32 0, 0 43 br i1 %tobool, label %if.then, label %if.end 44 45if.then: ; preds = %entry 46 store i32 ptrtoint (i32* @a to i32), i32* @c, align 4 47 br label %if.end 48 49if.end: ; preds = %if.then, %entry 50 %0 = load i32, i32* @c, align 4 51 %inc = add nsw i32 %0, 1 52 store i32 %inc, i32* @c, align 4 53 ret void 54} 55 56