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