@@ -212,3 +212,50 @@ func.func @unordered(%arg0: !fir.ref<!fir.array<100xf32>> , %arg1: !fir.ref<!fir
212212// CHECK: }
213213// CHECK: return
214214// CHECK: }
215+
216+ // Test vector saving subscripted LHS inside WHERE.
217+ !t=!fir.type<_QFwhere_vec_subscriptsTt{x:f32,vec:!fir.array<4xi64>}>
218+ func.func @_QPwhere_vec_subscripts(%arg0: !fir.ref<!fir.array<4x!fir.logical<4>>>, %arg1: !fir.box<!fir.array<?x!t>>) {
219+ %0 = fir.dummy_scope : !fir.dscope
220+ %1:2 = hlfir.declare %arg1 dummy_scope %0 {uniq_name = "_QFwhere_vec_subscriptsEa"} : (!fir.box<!fir.array<?x!t>>, !fir.dscope) -> (!fir.box<!fir.array<?x!t>>, !fir.box<!fir.array<?x!t>>)
221+ %c4 = arith.constant 4 : index
222+ %2 = fir.shape %c4 : (index) -> !fir.shape<1>
223+ %3:2 = hlfir.declare %arg0(%2) dummy_scope %0 {uniq_name = "_QFwhere_vec_subscriptsEmask"} : (!fir.ref<!fir.array<4x!fir.logical<4>>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<4x!fir.logical<4>>>, !fir.ref<!fir.array<4x!fir.logical<4>>>)
224+ hlfir.where {
225+ hlfir.yield %3#0 : !fir.ref<!fir.array<4x!fir.logical<4>>>
226+ } do {
227+ hlfir.region_assign {
228+ %cst = arith.constant 0.000000e+00 : f32
229+ hlfir.yield %cst : f32
230+ } to {
231+ %c1 = arith.constant 1 : index
232+ %4 = hlfir.designate %1#0 (%c1) : (!fir.box<!fir.array<?x!t>>, index) -> !fir.ref<!t>
233+ %6 = hlfir.designate %4{"vec"} shape %2 : (!fir.ref<!t>, !fir.shape<1>) -> !fir.ref<!fir.array<4xi64>>
234+ hlfir.elemental_addr %2 unordered : !fir.shape<1> {
235+ ^bb0(%arg2: index):
236+ %8 = hlfir.designate %6 (%arg2) : (!fir.ref<!fir.array<4xi64>>, index) -> !fir.ref<i64>
237+ %9 = fir.load %8 : !fir.ref<i64>
238+ %10 = hlfir.designate %1#0 (%9) : (!fir.box<!fir.array<?x!t>>, i64) -> !fir.ref<!t>
239+ %11 = hlfir.designate %10{"x"} : (!fir.ref<!t>) -> !fir.ref<f32>
240+ hlfir.yield %11 : !fir.ref<f32>
241+ }
242+ }
243+ }
244+ return
245+ }
246+ // CHECK-LABEL: func.func @_QPwhere_vec_subscripts(
247+ // CHECK: %[[VAL_16:.*]] = fir.call @_FortranACreateDescriptorStack(
248+ // CHECK: fir.do_loop {{.*}}
249+ // CHECK: fir.if %{{.*}} {
250+ // CHECK: fir.call @_FortranAPushDescriptor(
251+ // CHECK: }
252+ // CHECK: }
253+ // CHECK: fir.do_loop {{.*}}
254+ // CHECK: fir.if %{{.*}} {
255+ // CHECK: fir.call @_FortranADescriptorAt(
256+ // CHECK: hlfir.assign
257+ // CHECK: }
258+ // CHECK: }
259+ // CHECK: fir.call @_FortranADestroyDescriptorStack(
260+ // CHECK: return
261+ // CHECK: }
0 commit comments