1 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s
3 ; BasicAA should detect NoAliases in PHIs and Selects.
5 ; Two PHIs in the same block.
6 ; CHECK-LABEL: Function: foo
7 ; CHECK: NoAlias: double* %a, double* %b
8 define void @foo(i1 %m, ptr noalias %x, ptr noalias %y) {
10 br i1 %m, label %true, label %false
19 %a = phi ptr [ %x, %true ], [ %y, %false ]
20 %b = phi ptr [ %x, %false ], [ %y, %true ]
21 store volatile double 0.0, ptr %a
22 store volatile double 1.0, ptr %b
26 ; Two selects with the same condition.
27 ; CHECK-LABEL: Function: bar
28 ; CHECK: NoAlias: double* %a, double* %b
29 define void @bar(i1 %m, ptr noalias %x, ptr noalias %y) {
31 %a = select i1 %m, ptr %x, ptr %y
32 %b = select i1 %m, ptr %y, ptr %x
33 store volatile double 0.000000e+00, ptr %a
34 store volatile double 1.000000e+00, ptr %b
38 ; Two PHIs with disjoint sets of inputs.
39 ; CHECK-LABEL: Function: qux
40 ; CHECK: NoAlias: double* %a, double* %b
41 define void @qux(i1 %m, ptr noalias %x, ptr noalias %y,
42 i1 %n, ptr noalias %v, ptr noalias %w) {
44 br i1 %m, label %true, label %false
53 %a = phi ptr [ %x, %true ], [ %y, %false ]
54 br i1 %n, label %ntrue, label %nfalse
63 %b = phi ptr [ %v, %ntrue ], [ %w, %nfalse ]
64 store volatile double 0.0, ptr %a
65 store volatile double 1.0, ptr %b
69 ; Two selects with disjoint sets of arms.
70 ; CHECK-LABEL: Function: fin
71 ; CHECK: NoAlias: double* %a, double* %b
72 define void @fin(i1 %m, ptr noalias %x, ptr noalias %y,
73 i1 %n, ptr noalias %v, ptr noalias %w) {
75 %a = select i1 %m, ptr %x, ptr %y
76 %b = select i1 %n, ptr %v, ptr %w
77 store volatile double 0.000000e+00, ptr %a
78 store volatile double 1.000000e+00, ptr %b
82 ; On the first iteration, sel1 = a1, sel2 = a2, phi = a3
83 ; On the second iteration, sel1 = a2, sel1 = a1, phi = a2
84 ; As such, sel1 and phi may alias.
85 ; CHECK-LABEL: Function: select_backedge
86 ; CHECK: NoAlias: i32* %sel1, i32* %sel2
87 ; CHECK: MayAlias: i32* %phi, i32* %sel1
88 ; CHECK: MayAlias: i32* %phi, i32* %sel2
89 define void @select_backedge() {
97 %phi = phi ptr [ %a3, %entry ], [ %sel2, %loop ]
98 %c = phi i1 [ true, %entry ], [ false, %loop ]
99 %sel1 = select i1 %c, ptr %a1, ptr %a2
100 %sel2 = select i1 %c, ptr %a2, ptr %a1