blob: ed2d23e3adc9007604f2fe02905db17b44bc6047 [file] [log] [blame]
Chandler Carruth5da53432012-07-02 18:37:59 +00001; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
Arnold Schwaighofer0d10a9d2014-01-02 03:31:36 +00002; RUN: opt < %s -domtree -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s --check-prefix=DOM
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
Evan Chengc10e88d2009-10-13 22:02:20 +00006; rdar://7282591
7
Evan Chengc745bf22009-10-14 01:45:10 +00008@X = common global i32 0
9@Y = common global i32 0
10@Z = common global i32 0
Evan Chengc10e88d2009-10-13 22:02:20 +000011
Arnold Schwaighofer0d10a9d2014-01-02 03:31:36 +000012; CHECK-LABEL: foo
Bill Wendlingcd6df162012-04-24 09:15:38 +000013; CHECK: NoAlias: i32* %P, i32* @Z
14
Arnold Schwaighofer0d10a9d2014-01-02 03:31:36 +000015; DOM-LABEL: foo
16; DOM: NoAlias: i32* %P, i32* @Z
17
Dan Gohman22e0e1c2010-11-11 21:08:46 +000018define void @foo(i32 %cond) nounwind {
Evan Chengc10e88d2009-10-13 22:02:20 +000019entry:
Evan Chengc745bf22009-10-14 01:45:10 +000020 %"alloca point" = bitcast i32 0 to i32
21 %tmp = icmp ne i32 %cond, 0
22 br i1 %tmp, label %bb, label %bb1
Evan Chengc10e88d2009-10-13 22:02:20 +000023
Evan Chengc745bf22009-10-14 01:45:10 +000024bb:
25 br label %bb2
Evan Chengc10e88d2009-10-13 22:02:20 +000026
Evan Chengc745bf22009-10-14 01:45:10 +000027bb1:
28 br label %bb2
Evan Chengc10e88d2009-10-13 22:02:20 +000029
Evan Chengc745bf22009-10-14 01:45:10 +000030bb2:
31 %P = phi i32* [ @X, %bb ], [ @Y, %bb1 ]
32 %tmp1 = load i32* @Z, align 4
33 store i32 123, i32* %P, align 4
34 %tmp2 = load i32* @Z, align 4
35 br label %return
Evan Chengc10e88d2009-10-13 22:02:20 +000036
Evan Chengc745bf22009-10-14 01:45:10 +000037return:
Evan Chengc10e88d2009-10-13 22:02:20 +000038 ret void
39}
Arnold Schwaighofer0d10a9d2014-01-02 03:31:36 +000040
41; Pointers can vary in between iterations of loops.
42; PR18068
43
44; CHECK-LABEL: pr18068
45; CHECK: MayAlias: i32* %0, i32* %arrayidx5
46
47; DOM-LABEL: pr18068
48; DOM: MayAlias: i32* %0, i32* %arrayidx5
49
50define i32 @pr18068(i32* %jj7, i32* %j) {
51entry:
52 %oa5 = alloca [100 x i32], align 16
53 br label %codeRepl
54
55codeRepl:
56 %0 = phi i32* [ %arrayidx13, %for.body ], [ %j, %entry ]
57 %targetBlock = call i1 @cond(i32* %jj7)
58 br i1 %targetBlock, label %for.body, label %bye
59
60for.body:
61 %1 = load i32* %jj7, align 4
62 %idxprom4 = zext i32 %1 to i64
63 %arrayidx5 = getelementptr inbounds [100 x i32]* %oa5, i64 0, i64 %idxprom4
64 %2 = load i32* %arrayidx5, align 4
65 %sub6 = sub i32 %2, 6
66 store i32 %sub6, i32* %arrayidx5, align 4
67 ; %0 and %arrayidx5 can alias! It is not safe to DSE the above store.
68 %3 = load i32* %0, align 4
69 store i32 %3, i32* %arrayidx5, align 4
70 %sub11 = add i32 %1, -1
71 %idxprom12 = zext i32 %sub11 to i64
72 %arrayidx13 = getelementptr inbounds [100 x i32]* %oa5, i64 0, i64 %idxprom12
73 call void @inc(i32* %jj7)
74 br label %codeRepl
75
76bye:
77 %.reload = load i32* %jj7, align 4
78 ret i32 %.reload
79}
80
81declare i1 @cond(i32*)
82
83declare void @inc(i32*)
84
85