1 ; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -S -passes='require<globals-aa>,function(loop-mssa(licm))' | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.10.0"
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 ptr null, align 4
11 define void @foo(ptr %P) noinline {
12 ; CHECK: define void @foo
13 %loadp = load i32, ptr %P, align 4
14 store i32 %loadp, ptr @d, align 4
18 define void @bar() noinline {
19 ; CHECK: define void @bar
20 %loadp = load i32, ptr @d, align 4
21 store i32 %loadp, ptr @c, align 4
27 %retval = alloca i32, align 4
28 %c = alloca [1 x i32], align 4
29 store i32 0, ptr %retval, align 4
31 store i32 0, ptr @b, align 4
33 ;; Check that @c is LICM'ed out.
34 ; CHECK: load i32, ptr @c
35 for.cond: ; preds = %for.inc, %entry
36 ; CHECK-LABEL: for.cond:
37 ; CHECK: load i32, ptr @b
38 %a1 = load i32, ptr @b, align 4
39 %aa2 = load i32, ptr @c, align 4
40 %add = add nsw i32 %a1, %aa2
41 %p1 = load ptr, ptr @e, align 4
42 call void @foo(ptr %p1)
43 %cmp = icmp slt i32 %add, 3
44 br i1 %cmp, label %for.body, label %for.end
46 for.body: ; preds = %for.cond
47 %a2 = load i32, ptr @b, align 4
48 %idxprom = sext i32 %a2 to i64
51 for.inc: ; preds = %for.body
52 %a3 = load i32, ptr @b, align 4
53 %inc = add nsw i32 %a3, 1
54 store i32 %inc, ptr @b, align 4
57 for.end: ; preds = %for.cond
61 ; Function Attrs: nounwind argmemonly
62 declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind argmemonly
64 ; Function Attrs: noreturn nounwind
65 declare void @abort() noreturn nounwind