1 ! RUN: bbc -emit-fir %s -o - | FileCheck --check-prefixes="CHECK-FIR" %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --fir-to-llvm-ir | FileCheck --check-prefixes="CHECK-LLVMIR" %s
3 ! RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck --check-prefixes="CHECK" %s
4 ! REQUIRES: target=powerpc{{.*}}
8 !CHECK-LABEL: vec_insert_testf32
9 subroutine vec_insert_testf32(v
, x
, i1
, i2
, i4
, i8
)
17 r
= vec_insert(v
, x
, i1
)
18 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f32>
19 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
20 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
21 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:f32>) -> vector<4xf32>
22 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i8
23 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
24 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<4xf32>
25 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xf32>) -> !fir.vector<4:f32>
26 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
28 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f32>
29 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xf32>>
30 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
31 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i8) : i8
32 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
33 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<4xf32>
34 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xf32>>
36 ! CHECK: %[[v:.*]] = load float, ptr %{{[0-9]}}, align 4
37 ! CHECK: %[[x:.*]] = load <4 x float>, ptr %{{[0-9]}}, align 16
38 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
39 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 4
40 ! CHECK: %[[r:.*]] = insertelement <4 x float> %[[x]], float %[[v]], i8 %[[urem]]
41 ! CHECK: store <4 x float> %[[r]], ptr %{{[0-9]}}, align 16
44 r
= vec_insert(v
, x
, i2
)
45 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f32>
46 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
47 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
48 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:f32>) -> vector<4xf32>
49 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i16
50 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
51 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<4xf32>
52 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xf32>) -> !fir.vector<4:f32>
53 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
55 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f32>
56 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xf32>>
57 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
58 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i16) : i16
59 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
60 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<4xf32>
61 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xf32>>
63 ! CHECK: %[[v:.*]] = load float, ptr %{{[0-9]}}, align 4
64 ! CHECK: %[[x:.*]] = load <4 x float>, ptr %{{[0-9]}}, align 16
65 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
66 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 4
67 ! CHECK: %[[r:.*]] = insertelement <4 x float> %[[x]], float %[[v]], i16 %[[urem]]
68 ! CHECK: store <4 x float> %[[r]], ptr %{{[0-9]}}, align 16
70 r
= vec_insert(v
, x
, i4
)
71 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f32>
72 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
73 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
74 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:f32>) -> vector<4xf32>
75 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i32
76 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
77 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<4xf32>
78 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xf32>) -> !fir.vector<4:f32>
79 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
81 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f32>
82 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xf32>>
83 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
84 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i32) : i32
85 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
86 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<4xf32>
87 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xf32>>
89 ! CHECK: %[[v:.*]] = load float, ptr %{{[0-9]}}, align 4
90 ! CHECK: %[[x:.*]] = load <4 x float>, ptr %{{[0-9]}}, align 16
91 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
92 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 4
93 ! CHECK: %[[r:.*]] = insertelement <4 x float> %[[x]], float %[[v]], i32 %[[urem]]
94 ! CHECK: store <4 x float> %[[r]], ptr %{{[0-9]}}, align 16
96 r
= vec_insert(v
, x
, i8
)
97 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f32>
98 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
99 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
100 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:f32>) -> vector<4xf32>
101 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i64
102 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
103 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<4xf32>
104 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xf32>) -> !fir.vector<4:f32>
105 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:f32>>
107 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f32>
108 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xf32>>
109 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
110 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i64) : i64
111 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
112 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<4xf32>
113 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xf32>>
115 ! CHECK: %[[v:.*]] = load float, ptr %{{[0-9]}}, align 4
116 ! CHECK: %[[x:.*]] = load <4 x float>, ptr %{{[0-9]}}, align 16
117 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
118 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 4
119 ! CHECK: %[[r:.*]] = insertelement <4 x float> %[[x]], float %[[v]], i64 %[[urem]]
120 ! CHECK: store <4 x float> %[[r]], ptr %{{[0-9]}}, align 16
121 end subroutine vec_insert_testf32
123 !CHECK-LABEL: vec_insert_testf64
124 subroutine vec_insert_testf64(v
, x
, i1
, i2
, i4
, i8
)
132 r
= vec_insert(v
, x
, i1
)
133 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f64>
134 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
135 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
136 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:f64>) -> vector<2xf64>
137 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i8
138 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
139 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<2xf64>
140 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xf64>) -> !fir.vector<2:f64>
141 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
143 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f64>
144 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xf64>>
145 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
146 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i8) : i8
147 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
148 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<2xf64>
149 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xf64>>
151 ! CHECK: %[[v:.*]] = load double, ptr %{{[0-9]}}, align 8
152 ! CHECK: %[[x:.*]] = load <2 x double>, ptr %{{[0-9]}}, align 16
153 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
154 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 2
155 ! CHECK: %[[r:.*]] = insertelement <2 x double> %[[x]], double %[[v]], i8 %[[urem]]
156 ! CHECK: store <2 x double> %[[r]], ptr %{{[0-9]}}, align 16
159 r
= vec_insert(v
, x
, i2
)
160 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f64>
161 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
162 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
163 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:f64>) -> vector<2xf64>
164 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i16
165 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
166 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<2xf64>
167 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xf64>) -> !fir.vector<2:f64>
168 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
170 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f64>
171 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xf64>>
172 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
173 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i16) : i16
174 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
175 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<2xf64>
176 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xf64>>
178 ! CHECK: %[[v:.*]] = load double, ptr %{{[0-9]}}, align 8
179 ! CHECK: %[[x:.*]] = load <2 x double>, ptr %{{[0-9]}}, align 16
180 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
181 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 2
182 ! CHECK: %[[r:.*]] = insertelement <2 x double> %[[x]], double %[[v]], i16 %[[urem]]
183 ! CHECK: store <2 x double> %[[r]], ptr %{{[0-9]}}, align 16
185 r
= vec_insert(v
, x
, i4
)
186 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f64>
187 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
188 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
189 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:f64>) -> vector<2xf64>
190 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i32
191 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
192 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<2xf64>
193 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xf64>) -> !fir.vector<2:f64>
194 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
196 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f64>
197 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xf64>>
198 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
199 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i32) : i32
200 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
201 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<2xf64>
202 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xf64>>
204 ! CHECK: %[[v:.*]] = load double, ptr %{{[0-9]}}, align 8
205 ! CHECK: %[[x:.*]] = load <2 x double>, ptr %{{[0-9]}}, align 16
206 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
207 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 2
208 ! CHECK: %[[r:.*]] = insertelement <2 x double> %[[x]], double %[[v]], i32 %[[urem]]
209 ! CHECK: store <2 x double> %[[r]], ptr %{{[0-9]}}, align 16
211 r
= vec_insert(v
, x
, i8
)
212 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<f64>
213 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
214 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
215 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:f64>) -> vector<2xf64>
216 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i64
217 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
218 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<2xf64>
219 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xf64>) -> !fir.vector<2:f64>
220 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:f64>>
222 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<f64>
223 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xf64>>
224 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
225 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i64) : i64
226 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
227 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<2xf64>
228 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xf64>>
230 ! CHECK: %[[v:.*]] = load double, ptr %{{[0-9]}}, align 8
231 ! CHECK: %[[x:.*]] = load <2 x double>, ptr %{{[0-9]}}, align 16
232 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
233 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 2
234 ! CHECK: %[[r:.*]] = insertelement <2 x double> %[[x]], double %[[v]], i64 %[[urem]]
235 ! CHECK: store <2 x double> %[[r]], ptr %{{[0-9]}}, align 16
236 end subroutine vec_insert_testf64
238 !CHECK-LABEL: vec_insert_testi8
239 subroutine vec_insert_testi8(v
, x
, i1
, i2
, i4
, i8
)
241 vector(integer(1)) :: x
242 vector(integer(1)) :: r
247 r
= vec_insert(v
, x
, i1
)
248 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
249 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
250 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
251 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<16:i8>) -> vector<16xi8>
252 ! CHECK-FIR: %[[c:.*]] = arith.constant 16 : i8
253 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
254 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<16xi8>
255 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<16xi8>) -> !fir.vector<16:i8>
256 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
258 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
259 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<16xi8>>
260 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
261 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(16 : i8) : i8
262 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
263 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<16xi8>
264 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<16xi8>>
266 ! CHECK: %[[v:.*]] = load i8, ptr %{{[0-9]}}, align 1
267 ! CHECK: %[[x:.*]] = load <16 x i8>, ptr %{{[0-9]}}, align 16
268 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
269 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 16
270 ! CHECK: %[[r:.*]] = insertelement <16 x i8> %[[x]], i8 %[[v]], i8 %[[urem]]
271 ! CHECK: store <16 x i8> %[[r]], ptr %{{[0-9]}}, align 16
274 r
= vec_insert(v
, x
, i2
)
275 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
276 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
277 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
278 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<16:i8>) -> vector<16xi8>
279 ! CHECK-FIR: %[[c:.*]] = arith.constant 16 : i16
280 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
281 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<16xi8>
282 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<16xi8>) -> !fir.vector<16:i8>
283 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
285 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
286 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<16xi8>>
287 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
288 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(16 : i16) : i16
289 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
290 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<16xi8>
291 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<16xi8>>
293 ! CHECK: %[[v:.*]] = load i8, ptr %{{[0-9]}}, align 1
294 ! CHECK: %[[x:.*]] = load <16 x i8>, ptr %{{[0-9]}}, align 16
295 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
296 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 16
297 ! CHECK: %[[r:.*]] = insertelement <16 x i8> %[[x]], i8 %[[v]], i16 %[[urem]]
298 ! CHECK: store <16 x i8> %[[r]], ptr %{{[0-9]}}, align 16
300 r
= vec_insert(v
, x
, i4
)
301 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
302 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
303 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
304 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<16:i8>) -> vector<16xi8>
305 ! CHECK-FIR: %[[c:.*]] = arith.constant 16 : i32
306 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
307 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<16xi8>
308 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<16xi8>) -> !fir.vector<16:i8>
309 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
311 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
312 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<16xi8>>
313 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
314 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(16 : i32) : i32
315 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
316 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<16xi8>
317 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<16xi8>>
319 ! CHECK: %[[v:.*]] = load i8, ptr %{{[0-9]}}, align 1
320 ! CHECK: %[[x:.*]] = load <16 x i8>, ptr %{{[0-9]}}, align 16
321 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
322 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 16
323 ! CHECK: %[[r:.*]] = insertelement <16 x i8> %[[x]], i8 %[[v]], i32 %[[urem]]
324 ! CHECK: store <16 x i8> %[[r]], ptr %{{[0-9]}}, align 16
326 r
= vec_insert(v
, x
, i8
)
327 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
328 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
329 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
330 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<16:i8>) -> vector<16xi8>
331 ! CHECK-FIR: %[[c:.*]] = arith.constant 16 : i64
332 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
333 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<16xi8>
334 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<16xi8>) -> !fir.vector<16:i8>
335 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<16:i8>>
337 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
338 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<16xi8>>
339 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
340 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(16 : i64) : i64
341 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
342 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<16xi8>
343 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<16xi8>>
345 ! CHECK: %[[v:.*]] = load i8, ptr %{{[0-9]}}, align 1
346 ! CHECK: %[[x:.*]] = load <16 x i8>, ptr %{{[0-9]}}, align 16
347 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
348 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 16
349 ! CHECK: %[[r:.*]] = insertelement <16 x i8> %[[x]], i8 %[[v]], i64 %[[urem]]
350 ! CHECK: store <16 x i8> %[[r]], ptr %{{[0-9]}}, align 16
351 end subroutine vec_insert_testi8
353 !CHECK-LABEL: vec_insert_testi16
354 subroutine vec_insert_testi16(v
, x
, i1
, i2
, i4
, i8
)
356 vector(integer(2)) :: x
357 vector(integer(2)) :: r
362 r
= vec_insert(v
, x
, i1
)
363 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
364 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
365 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
366 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<8:i16>) -> vector<8xi16>
367 ! CHECK-FIR: %[[c:.*]] = arith.constant 8 : i8
368 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
369 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<8xi16>
370 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<8xi16>) -> !fir.vector<8:i16>
371 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
373 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
374 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<8xi16>>
375 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
376 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(8 : i8) : i8
377 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
378 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<8xi16>
379 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<8xi16>>
381 ! CHECK: %[[v:.*]] = load i16, ptr %{{[0-9]}}, align 2
382 ! CHECK: %[[x:.*]] = load <8 x i16>, ptr %{{[0-9]}}, align 16
383 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
384 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 8
385 ! CHECK: %[[r:.*]] = insertelement <8 x i16> %[[x]], i16 %[[v]], i8 %[[urem]]
386 ! CHECK: store <8 x i16> %[[r]], ptr %{{[0-9]}}, align 16
389 r
= vec_insert(v
, x
, i2
)
390 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
391 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
392 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
393 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<8:i16>) -> vector<8xi16>
394 ! CHECK-FIR: %[[c:.*]] = arith.constant 8 : i16
395 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
396 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<8xi16>
397 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<8xi16>) -> !fir.vector<8:i16>
398 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
400 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
401 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<8xi16>>
402 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
403 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(8 : i16) : i16
404 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
405 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<8xi16>
406 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<8xi16>>
408 ! CHECK: %[[v:.*]] = load i16, ptr %{{[0-9]}}, align 2
409 ! CHECK: %[[x:.*]] = load <8 x i16>, ptr %{{[0-9]}}, align 16
410 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
411 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 8
412 ! CHECK: %[[r:.*]] = insertelement <8 x i16> %[[x]], i16 %[[v]], i16 %[[urem]]
413 ! CHECK: store <8 x i16> %[[r]], ptr %{{[0-9]}}, align 16
415 r
= vec_insert(v
, x
, i4
)
416 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
417 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
418 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
419 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<8:i16>) -> vector<8xi16>
420 ! CHECK-FIR: %[[c:.*]] = arith.constant 8 : i32
421 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
422 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<8xi16>
423 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<8xi16>) -> !fir.vector<8:i16>
424 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
426 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
427 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<8xi16>>
428 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
429 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(8 : i32) : i32
430 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
431 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<8xi16>
432 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<8xi16>>
434 ! CHECK: %[[v:.*]] = load i16, ptr %{{[0-9]}}, align 2
435 ! CHECK: %[[x:.*]] = load <8 x i16>, ptr %{{[0-9]}}, align 16
436 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
437 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 8
438 ! CHECK: %[[r:.*]] = insertelement <8 x i16> %[[x]], i16 %[[v]], i32 %[[urem]]
439 ! CHECK: store <8 x i16> %[[r]], ptr %{{[0-9]}}, align 16
441 r
= vec_insert(v
, x
, i8
)
442 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
443 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
444 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
445 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<8:i16>) -> vector<8xi16>
446 ! CHECK-FIR: %[[c:.*]] = arith.constant 8 : i64
447 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
448 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<8xi16>
449 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<8xi16>) -> !fir.vector<8:i16>
450 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<8:i16>>
452 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
453 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<8xi16>>
454 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
455 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(8 : i64) : i64
456 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
457 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<8xi16>
458 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<8xi16>>
460 ! CHECK: %[[v:.*]] = load i16, ptr %{{[0-9]}}, align 2
461 ! CHECK: %[[x:.*]] = load <8 x i16>, ptr %{{[0-9]}}, align 16
462 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
463 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 8
464 ! CHECK: %[[r:.*]] = insertelement <8 x i16> %[[x]], i16 %[[v]], i64 %[[urem]]
465 ! CHECK: store <8 x i16> %[[r]], ptr %{{[0-9]}}, align 16
466 end subroutine vec_insert_testi16
468 !CHECK-LABEL: vec_insert_testi32
469 subroutine vec_insert_testi32(v
, x
, i1
, i2
, i4
, i8
)
471 vector(integer(4)) :: x
472 vector(integer(4)) :: r
477 r
= vec_insert(v
, x
, i1
)
478 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
479 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
480 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
481 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:i32>) -> vector<4xi32>
482 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i8
483 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
484 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<4xi32>
485 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xi32>) -> !fir.vector<4:i32>
486 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
488 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
489 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xi32>>
490 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
491 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i8) : i8
492 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
493 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<4xi32>
494 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xi32>>
496 ! CHECK: %[[v:.*]] = load i32, ptr %{{[0-9]}}, align 4
497 ! CHECK: %[[x:.*]] = load <4 x i32>, ptr %{{[0-9]}}, align 16
498 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
499 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 4
500 ! CHECK: %[[r:.*]] = insertelement <4 x i32> %[[x]], i32 %[[v]], i8 %[[urem]]
501 ! CHECK: store <4 x i32> %[[r]], ptr %{{[0-9]}}, align 16
504 r
= vec_insert(v
, x
, i2
)
505 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
506 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
507 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
508 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:i32>) -> vector<4xi32>
509 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i16
510 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
511 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<4xi32>
512 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xi32>) -> !fir.vector<4:i32>
513 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
515 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
516 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xi32>>
517 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
518 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i16) : i16
519 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
520 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<4xi32>
521 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xi32>>
523 ! CHECK: %[[v:.*]] = load i32, ptr %{{[0-9]}}, align 4
524 ! CHECK: %[[x:.*]] = load <4 x i32>, ptr %{{[0-9]}}, align 16
525 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
526 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 4
527 ! CHECK: %[[r:.*]] = insertelement <4 x i32> %[[x]], i32 %[[v]], i16 %[[urem]]
528 ! CHECK: store <4 x i32> %[[r]], ptr %{{[0-9]}}, align 16
530 r
= vec_insert(v
, x
, i4
)
531 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
532 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
533 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
534 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:i32>) -> vector<4xi32>
535 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i32
536 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
537 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<4xi32>
538 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xi32>) -> !fir.vector<4:i32>
539 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
541 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
542 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xi32>>
543 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
544 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i32) : i32
545 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
546 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<4xi32>
547 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xi32>>
549 ! CHECK: %[[v:.*]] = load i32, ptr %{{[0-9]}}, align 4
550 ! CHECK: %[[x:.*]] = load <4 x i32>, ptr %{{[0-9]}}, align 16
551 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
552 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 4
553 ! CHECK: %[[r:.*]] = insertelement <4 x i32> %[[x]], i32 %[[v]], i32 %[[urem]]
554 ! CHECK: store <4 x i32> %[[r]], ptr %{{[0-9]}}, align 16
556 r
= vec_insert(v
, x
, i8
)
557 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
558 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
559 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
560 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<4:i32>) -> vector<4xi32>
561 ! CHECK-FIR: %[[c:.*]] = arith.constant 4 : i64
562 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
563 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<4xi32>
564 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<4xi32>) -> !fir.vector<4:i32>
565 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<4:i32>>
567 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
568 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<4xi32>>
569 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
570 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(4 : i64) : i64
571 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
572 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<4xi32>
573 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<4xi32>>
575 ! CHECK: %[[v:.*]] = load i32, ptr %{{[0-9]}}, align 4
576 ! CHECK: %[[x:.*]] = load <4 x i32>, ptr %{{[0-9]}}, align 16
577 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
578 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 4
579 ! CHECK: %[[r:.*]] = insertelement <4 x i32> %[[x]], i32 %[[v]], i64 %[[urem]]
580 ! CHECK: store <4 x i32> %[[r]], ptr %{{[0-9]}}, align 16
581 end subroutine vec_insert_testi32
584 !CHECK-LABEL: vec_insert_testi64
585 subroutine vec_insert_testi64(v
, x
, i1
, i2
, i4
, i8
)
587 vector(integer(8)) :: x
588 vector(integer(8)) :: r
593 r
= vec_insert(v
, x
, i1
)
594 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
595 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
596 ! CHECK-FIR: %[[i1:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i8>
597 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:i64>) -> vector<2xi64>
598 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i8
599 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
600 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i8] : vector<2xi64>
601 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xi64>) -> !fir.vector<2:i64>
602 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
604 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
605 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xi64>>
606 ! CHECK-LLVMIR: %[[i1:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i8>
607 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i8) : i8
608 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i1]], %[[c]] : i8
609 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i8] : vector<2xi64>
610 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xi64>>
612 ! CHECK: %[[v:.*]] = load i64, ptr %{{[0-9]}}, align 8
613 ! CHECK: %[[x:.*]] = load <2 x i64>, ptr %{{[0-9]}}, align 16
614 ! CHECK: %[[i1:.*]] = load i8, ptr %{{[0-9]}}, align 1
615 ! CHECK: %[[urem:.*]] = urem i8 %[[i1]], 2
616 ! CHECK: %[[r:.*]] = insertelement <2 x i64> %[[x]], i64 %[[v]], i8 %[[urem]]
617 ! CHECK: store <2 x i64> %[[r]], ptr %{{[0-9]}}, align 16
620 r
= vec_insert(v
, x
, i2
)
621 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
622 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
623 ! CHECK-FIR: %[[i2:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i16>
624 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:i64>) -> vector<2xi64>
625 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i16
626 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
627 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i16] : vector<2xi64>
628 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xi64>) -> !fir.vector<2:i64>
629 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
631 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
632 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xi64>>
633 ! CHECK-LLVMIR: %[[i2:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i16>
634 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i16) : i16
635 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i2]], %[[c]] : i16
636 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i16] : vector<2xi64>
637 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xi64>>
639 ! CHECK: %[[v:.*]] = load i64, ptr %{{[0-9]}}, align 8
640 ! CHECK: %[[x:.*]] = load <2 x i64>, ptr %{{[0-9]}}, align 16
641 ! CHECK: %[[i2:.*]] = load i16, ptr %{{[0-9]}}, align 2
642 ! CHECK: %[[urem:.*]] = urem i16 %[[i2]], 2
643 ! CHECK: %[[r:.*]] = insertelement <2 x i64> %[[x]], i64 %[[v]], i16 %[[urem]]
644 ! CHECK: store <2 x i64> %[[r]], ptr %{{[0-9]}}, align 16
646 r
= vec_insert(v
, x
, i4
)
647 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
648 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
649 ! CHECK-FIR: %[[i4:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i32>
650 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:i64>) -> vector<2xi64>
651 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i32
652 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
653 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i32] : vector<2xi64>
654 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xi64>) -> !fir.vector<2:i64>
655 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
657 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
658 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xi64>>
659 ! CHECK-LLVMIR: %[[i4:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i32>
660 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i32) : i32
661 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i4]], %[[c]] : i32
662 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i32] : vector<2xi64>
663 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xi64>>
665 ! CHECK: %[[v:.*]] = load i64, ptr %{{[0-9]}}, align 8
666 ! CHECK: %[[x:.*]] = load <2 x i64>, ptr %{{[0-9]}}, align 16
667 ! CHECK: %[[i4:.*]] = load i32, ptr %{{[0-9]}}, align 4
668 ! CHECK: %[[urem:.*]] = urem i32 %[[i4]], 2
669 ! CHECK: %[[r:.*]] = insertelement <2 x i64> %[[x]], i64 %[[v]], i32 %[[urem]]
670 ! CHECK: store <2 x i64> %[[r]], ptr %{{[0-9]}}, align 16
672 r
= vec_insert(v
, x
, i8
)
673 ! CHECK-FIR: %[[v:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
674 ! CHECK-FIR: %[[x:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
675 ! CHECK-FIR: %[[i8:.*]] = fir.load %arg{{[0-9]}} : !fir.ref<i64>
676 ! CHECK-FIR: %[[vr:.*]] = fir.convert %[[x]] : (!fir.vector<2:i64>) -> vector<2xi64>
677 ! CHECK-FIR: %[[c:.*]] = arith.constant 2 : i64
678 ! CHECK-FIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
679 ! CHECK-FIR: %[[r:.*]] = vector.insertelement %[[v]], %[[vr]][%[[urem]] : i64] : vector<2xi64>
680 ! CHECK-FIR: %[[r_conv:.*]] = fir.convert %[[r]] : (vector<2xi64>) -> !fir.vector<2:i64>
681 ! CHECK-FIR: fir.store %[[r_conv]] to %{{[0-9]}} : !fir.ref<!fir.vector<2:i64>>
683 ! CHECK-LLVMIR: %[[v:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
684 ! CHECK-LLVMIR: %[[x:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<vector<2xi64>>
685 ! CHECK-LLVMIR: %[[i8:.*]] = llvm.load %arg{{[0-9]}} : !llvm.ptr<i64>
686 ! CHECK-LLVMIR: %[[c:.*]] = llvm.mlir.constant(2 : i64) : i64
687 ! CHECK-LLVMIR: %[[urem:.*]] = llvm.urem %[[i8]], %[[c]] : i64
688 ! CHECK-LLVMIR: %[[r:.*]] = llvm.insertelement %[[v]], %[[x]][%[[urem]] : i64] : vector<2xi64>
689 ! CHECK-LLVMIR: llvm.store %[[r]], %{{[0-9]}} : !llvm.ptr<vector<2xi64>>
691 ! CHECK: %[[v:.*]] = load i64, ptr %{{[0-9]}}, align 8
692 ! CHECK: %[[x:.*]] = load <2 x i64>, ptr %{{[0-9]}}, align 16
693 ! CHECK: %[[i8:.*]] = load i64, ptr %{{[0-9]}}, align 8
694 ! CHECK: %[[urem:.*]] = urem i64 %[[i8]], 2
695 ! CHECK: %[[r:.*]] = insertelement <2 x i64> %[[x]], i64 %[[v]], i64 %[[urem]]
696 ! CHECK: store <2 x i64> %[[r]], ptr %{{[0-9]}}, align 16
697 end subroutine vec_insert_testi64