blob: b8fee00ed0d0426fc2f9e35c1c08774f29b46a5e [file] [log] [blame]
Chandler Carruth49589f02012-07-02 18:37:59 +00001; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
Dan Gohman6665b0e2009-10-26 21:55:43 +00002
3; BasicAA should detect NoAliases in PHIs and Selects.
4
Bill Wendlingd5cc8b82012-04-24 09:15:38 +00005; CHECK: Function: foo
6; CHECK: NoAlias: double* %a, double* %b
7; CHECK: Function: bar
8; CHECK: NoAlias: double* %a, double* %b
9; CHECK: Function: qux
10; CHECK: NoAlias: double* %a, double* %b
11; CHECK: Function: fin
12; CHECK: NoAlias: double* %a, double* %b
13; CHECK: ===== Alias Analysis Evaluator Report =====
14
Dan Gohman6665b0e2009-10-26 21:55:43 +000015; Two PHIs in the same block.
16define void @foo(i1 %m, double* noalias %x, double* noalias %y) {
17entry:
18 br i1 %m, label %true, label %false
19
20true:
21 br label %exit
22
23false:
24 br label %exit
25
26exit:
27 %a = phi double* [ %x, %true ], [ %y, %false ]
28 %b = phi double* [ %x, %false ], [ %y, %true ]
Chris Lattnerd2bf4322011-11-27 06:54:59 +000029 store volatile double 0.0, double* %a
30 store volatile double 1.0, double* %b
Dan Gohman6665b0e2009-10-26 21:55:43 +000031 ret void
32}
33
34; Two selects with the same condition.
35define void @bar(i1 %m, double* noalias %x, double* noalias %y) {
36entry:
37 %a = select i1 %m, double* %x, double* %y
38 %b = select i1 %m, double* %y, double* %x
Chris Lattnerd2bf4322011-11-27 06:54:59 +000039 store volatile double 0.000000e+00, double* %a
40 store volatile double 1.000000e+00, double* %b
Dan Gohman6665b0e2009-10-26 21:55:43 +000041 ret void
42}
43
44; Two PHIs with disjoint sets of inputs.
45define void @qux(i1 %m, double* noalias %x, double* noalias %y,
46 i1 %n, double* noalias %v, double* noalias %w) {
47entry:
48 br i1 %m, label %true, label %false
49
50true:
51 br label %exit
52
53false:
54 br label %exit
55
56exit:
57 %a = phi double* [ %x, %true ], [ %y, %false ]
58 br i1 %n, label %ntrue, label %nfalse
59
60ntrue:
61 br label %nexit
62
63nfalse:
64 br label %nexit
65
66nexit:
67 %b = phi double* [ %v, %ntrue ], [ %w, %nfalse ]
Chris Lattnerd2bf4322011-11-27 06:54:59 +000068 store volatile double 0.0, double* %a
69 store volatile double 1.0, double* %b
Dan Gohman6665b0e2009-10-26 21:55:43 +000070 ret void
71}
72
73; Two selects with disjoint sets of arms.
74define void @fin(i1 %m, double* noalias %x, double* noalias %y,
75 i1 %n, double* noalias %v, double* noalias %w) {
76entry:
77 %a = select i1 %m, double* %x, double* %y
78 %b = select i1 %n, double* %v, double* %w
Chris Lattnerd2bf4322011-11-27 06:54:59 +000079 store volatile double 0.000000e+00, double* %a
80 store volatile double 1.000000e+00, double* %b
Dan Gohman6665b0e2009-10-26 21:55:43 +000081 ret void
82}