1; RUN: opt < %s -basic-aa -globals-aa -S -licm -enable-new-pm=0 | FileCheck %s 2; RUN: opt < %s -basic-aa -globals-aa -S -licm -enable-new-pm=1 | FileCheck %s 3 4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 5target triple = "x86_64-apple-macosx10.10.0" 6 7@b = common global i32 0, align 4 8@c = internal global i32 0, align 4 9@d = common global i32 0, align 4 10@e = common global i32* null, align 4 11 12define void @foo(i32* %P) noinline { 13; CHECK: define void @foo 14 %loadp = load i32, i32* %P, align 4 15 store i32 %loadp, i32* @d, align 4 16 ret void 17} 18 19define void @bar() noinline { 20; CHECK: define void @bar 21 %loadp = load i32, i32* @d, align 4 22 store i32 %loadp, i32* @c, align 4 23 ret void 24} 25 26define i32 @main() { 27entry: 28 %retval = alloca i32, align 4 29 %c = alloca [1 x i32], align 4 30 store i32 0, i32* %retval, align 4 31 call void @bar() 32 store i32 0, i32* @b, align 4 33 br label %for.cond 34 ;; Check that @c is LICM'ed out. 35; CHECK: load i32, i32* @c 36for.cond: ; preds = %for.inc, %entry 37; CHECK-LABEL: for.cond: 38; CHECK: load i32, i32* @b 39 %a1 = load i32, i32* @b, align 4 40 %aa2 = load i32, i32* @c, align 4 41 %add = add nsw i32 %a1, %aa2 42 %p1 = load i32*, i32** @e, align 4 43 call void @foo(i32* %p1) 44 %cmp = icmp slt i32 %add, 3 45 br i1 %cmp, label %for.body, label %for.end 46 47for.body: ; preds = %for.cond 48 %a2 = load i32, i32* @b, align 4 49 %idxprom = sext i32 %a2 to i64 50 br label %for.inc 51 52for.inc: ; preds = %for.body 53 %a3 = load i32, i32* @b, align 4 54 %inc = add nsw i32 %a3, 1 55 store i32 %inc, i32* @b, align 4 56 br label %for.cond 57 58for.end: ; preds = %for.cond 59 ret i32 0 60} 61 62; Function Attrs: nounwind argmemonly 63declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind argmemonly 64 65; Function Attrs: noreturn nounwind 66declare void @abort() noreturn nounwind 67