1 ; RUN: opt -loop-vectorize -force-vector-width=2 -S %s | FileCheck %s
3 %s1 = type { [32000 x double], [32000 x double], [32000 x double] }
5 define i32 @load_with_pointer_phi_no_runtime_checks(%s1* %data) {
6 ; CHECK-LABEL: @load_with_pointer_phi_no_runtime_checks
7 ; CHECK-NOT: vector.body
12 loop.header: ; preds = %loop.latch, %entry
13 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
14 %iv.next = add nuw nsw i64 %iv, 1
15 %cmp5 = icmp ult i64 %iv, 15999
16 %arrayidx = getelementptr inbounds %s1, %s1 * %data, i64 0, i32 0, i64 %iv
17 br i1 %cmp5, label %if.then, label %if.else
19 if.then: ; preds = %loop.header
20 %gep.1 = getelementptr inbounds %s1, %s1* %data, i64 0, i32 1, i64 %iv
23 if.else: ; preds = %loop.header
24 %gep.2 = getelementptr inbounds %s1, %s1* %data, i64 0, i32 2, i64 %iv
27 loop.latch: ; preds = %if.else, %if.then
28 %gep.2.sink = phi double* [ %gep.2, %if.else ], [ %gep.1, %if.then ]
29 %v8 = load double, double* %gep.2.sink, align 8
30 %mul16 = fmul double 3.0, %v8
31 store double %mul16, double* %arrayidx, align 8
32 %exitcond.not = icmp eq i64 %iv.next, 32000
33 br i1 %exitcond.not, label %exit, label %loop.header
35 exit: ; preds = %loop.latch
39 define i32 @store_with_pointer_phi_no_runtime_checks(%s1* %data) {
40 ; CHECK-LABEL: @store_with_pointer_phi_no_runtime_checks
41 ; CHECK-NOT: vector.body
46 loop.header: ; preds = %loop.latch, %entry
47 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
48 %iv.next = add nuw nsw i64 %iv, 1
49 %cmp5 = icmp ult i64 %iv, 15999
50 %arrayidx = getelementptr inbounds %s1, %s1 * %data, i64 0, i32 0, i64 %iv
51 br i1 %cmp5, label %if.then, label %if.else
53 if.then: ; preds = %loop.header
54 %gep.1 = getelementptr inbounds %s1, %s1* %data, i64 0, i32 1, i64 %iv
57 if.else: ; preds = %loop.header
58 %gep.2 = getelementptr inbounds %s1, %s1* %data, i64 0, i32 2, i64 %iv
61 loop.latch: ; preds = %if.else, %if.then
62 %gep.2.sink = phi double* [ %gep.2, %if.else ], [ %gep.1, %if.then ]
63 %v8 = load double, double* %arrayidx, align 8
64 %mul16 = fmul double 3.0, %v8
65 store double %mul16, double* %gep.2.sink, align 8
66 %exitcond.not = icmp eq i64 %iv.next, 32000
67 br i1 %exitcond.not, label %exit, label %loop.header
69 exit: ; preds = %loop.latch
73 define i32 @store_with_pointer_phi_runtime_checks(double* %A, double* %B, double* %C) {
74 ; CHECK-LABEL: @store_with_pointer_phi_runtime_checks
75 ; CHECK-NOT: vector.body
80 loop.header: ; preds = %loop.latch, %entry
81 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
82 %iv.next = add nuw nsw i64 %iv, 1
83 %cmp5 = icmp ult i64 %iv, 15999
84 %arrayidx = getelementptr inbounds double, double* %A, i64 %iv
85 br i1 %cmp5, label %if.then, label %if.else
87 if.then: ; preds = %loop.header
88 %gep.1 = getelementptr inbounds double, double* %B, i64 %iv
91 if.else: ; preds = %loop.header
92 %gep.2 = getelementptr inbounds double, double* %C, i64 %iv
95 loop.latch: ; preds = %if.else, %if.then
96 %gep.2.sink = phi double* [ %gep.2, %if.else ], [ %gep.1, %if.then ]
97 %v8 = load double, double* %arrayidx, align 8
98 %mul16 = fmul double 3.0, %v8
99 store double %mul16, double* %gep.2.sink, align 8
100 %exitcond.not = icmp eq i64 %iv.next, 32000
101 br i1 %exitcond.not, label %exit, label %loop.header
103 exit: ; preds = %loop.latch
107 define i32 @load_with_pointer_phi_outside_loop(double* %A, double* %B, double* %C, i1 %c.0, i1 %c.1) {
108 ; CHECK-LABEL: @load_with_pointer_phi_outside_loop
109 ; CHECK-NOT: vector.body
112 br i1 %c.0, label %if.then, label %if.else
118 %ptr.select = select i1 %c.1, double* %C, double* %B
122 %ptr = phi double* [ %A, %if.then ], [ %ptr.select, %if.else ]
123 br label %loop.header
125 loop.header: ; preds = %loop.latch, %entry
126 %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop.header ]
127 %iv.next = add nuw nsw i64 %iv, 1
128 %arrayidx = getelementptr inbounds double, double* %A, i64 %iv
129 %v8 = load double, double* %ptr, align 8
130 %mul16 = fmul double 3.0, %v8
131 store double %mul16, double* %arrayidx, align 8
132 %exitcond.not = icmp eq i64 %iv.next, 32000
133 br i1 %exitcond.not, label %exit, label %loop.header
135 exit: ; preds = %loop.latch
139 define i32 @store_with_pointer_phi_outside_loop(double* %A, double* %B, double* %C, i1 %c.0, i1 %c.1) {
140 ; CHECK-LABEL: @store_with_pointer_phi_outside_loop
141 ; CHECK-NOT: vector.body
144 br i1 %c.0, label %if.then, label %if.else
150 %ptr.select = select i1 %c.1, double* %C, double* %B
154 %ptr = phi double* [ %A, %if.then ], [ %ptr.select, %if.else ]
155 br label %loop.header
157 loop.header: ; preds = %loop.latch, %entry
158 %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop.header ]
159 %iv.next = add nuw nsw i64 %iv, 1
160 %arrayidx = getelementptr inbounds double, double* %A, i64 %iv
161 %v8 = load double, double* %arrayidx, align 8
162 %mul16 = fmul double 3.0, %v8
163 store double %mul16, double* %ptr, align 8
164 %exitcond.not = icmp eq i64 %iv.next, 32000
165 br i1 %exitcond.not, label %exit, label %loop.header
167 exit: ; preds = %loop.latch