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
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.10.0"
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
12 define 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
19 define void @bar() noinline {
20 ; CHECK: define void @bar
21 %loadp = load i32, i32* @d, align 4
22 store i32 %loadp, i32* @c, align 4
28 %retval = alloca i32, align 4
29 %c = alloca [1 x i32], align 4
30 store i32 0, i32* %retval, align 4
32 store i32 0, i32* @b, align 4
34 ;; Check that @c is LICM'ed out.
35 ; CHECK: load i32, i32* @c
36 for.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
47 for.body: ; preds = %for.cond
48 %a2 = load i32, i32* @b, align 4
49 %idxprom = sext i32 %a2 to i64
52 for.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
58 for.end: ; preds = %for.cond
62 ; Function Attrs: nounwind argmemonly
63 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind argmemonly
65 ; Function Attrs: noreturn nounwind
66 declare void @abort() noreturn nounwind