1 // Test hlfir.elemental code generation
2 // RUN: fir-opt %s --bufferize-hlfir | FileCheck %s
4 func.func @numeric_type(%arg0: !fir.ref<!fir.array<10x20xi32>>, %arg1: !fir.ref<!fir.array<10x20xi32>>) {
5 %c10 = arith.constant 10 : index
6 %c20 = arith.constant 20 : index
7 %0 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
8 %1 = hlfir.elemental %0 : (!fir.shape<2>) -> !hlfir.expr<10x20xi32> {
9 ^bb0(%arg2: index, %arg3: index):
10 %2 = hlfir.designate %arg0 (%arg2, %arg3) : (!fir.ref<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
11 %3 = hlfir.designate %arg1 (%arg2, %arg3) : (!fir.ref<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
12 %4 = fir.load %2 : !fir.ref<i32>
13 %5 = fir.load %3 : !fir.ref<i32>
14 %6 = arith.addi %4, %5 : i32
15 hlfir.yield_element %6 : i32
19 // CHECK-LABEL: func.func @numeric_type(
20 // CHECK-SAME: %[[VAL_0:[^:]*]]: !fir.ref<!fir.array<10x20xi32>>,
21 // CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<10x20xi32>>) {
22 // CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
23 // CHECK: %[[VAL_3:.*]] = arith.constant 20 : index
24 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
25 // CHECK: %[[VAL_5:.*]] = fir.allocmem !fir.array<10x20xi32> {bindc_name = ".tmp.array", uniq_name = ""}
26 // CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_4]]) {uniq_name = ".tmp.array"} : (!fir.heap<!fir.array<10x20xi32>>, !fir.shape<2>) -> (!fir.heap<!fir.array<10x20xi32>>, !fir.heap<!fir.array<10x20xi32>>)
27 // CHECK: %[[VAL_7:.*]] = arith.constant true
28 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
29 // CHECK: fir.do_loop %[[VAL_9:.*]] = %[[VAL_8]] to %[[VAL_3]] step %[[VAL_8]] {
30 // CHECK: fir.do_loop %[[VAL_10:.*]] = %[[VAL_8]] to %[[VAL_2]] step %[[VAL_8]] {
31 // CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_10]], %[[VAL_9]]) : (!fir.ref<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
32 // CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_1]] (%[[VAL_10]], %[[VAL_9]]) : (!fir.ref<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
33 // CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_11]] : !fir.ref<i32>
34 // CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_12]] : !fir.ref<i32>
35 // CHECK: %[[VAL_15:.*]] = arith.addi %[[VAL_13]], %[[VAL_14]] : i32
36 // CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_10]], %[[VAL_9]]) : (!fir.heap<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
37 // CHECK: hlfir.assign %[[VAL_15]] to %[[VAL_16]] temporary_lhs : i32, !fir.ref<i32>
40 // CHECK: %[[VAL_17:.*]] = fir.undefined tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
41 // CHECK: %[[VAL_18:.*]] = fir.insert_value %[[VAL_17]], %[[VAL_7]], [1 : index] : (tuple<!fir.heap<!fir.array<10x20xi32>>, i1>, i1) -> tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
42 // CHECK: %[[VAL_19:.*]] = fir.insert_value %[[VAL_18]], %[[VAL_6]]#0, [0 : index] : (tuple<!fir.heap<!fir.array<10x20xi32>>, i1>, !fir.heap<!fir.array<10x20xi32>>) -> tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
45 func.func @char_type(%arg0: !fir.box<!fir.array<?x!fir.char<1,?>>>, %arg1: index, %arg2: index, %arg3: index) {
46 %0 = fir.shape %arg1 : (index) -> !fir.shape<1>
47 %1 = hlfir.elemental %0 typeparams %arg2 : (!fir.shape<1>, index) -> !hlfir.expr<?x!fir.char<1,?>> {
49 %2 = hlfir.designate %arg0 (%arg4) typeparams %arg3 : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
50 %3 = hlfir.concat %2, %2 len %arg2 : (!fir.boxchar<1>, !fir.boxchar<1>, index) -> !hlfir.expr<!fir.char<1,?>>
51 hlfir.yield_element %3 : !hlfir.expr<!fir.char<1,?>>
55 // CHECK-LABEL: func.func @char_type(
56 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>,
57 // CHECK-SAME: %[[VAL_1:[^:]*]]: index,
58 // CHECK-SAME: %[[VAL_2:[^:]*]]: index,
59 // CHECK-SAME: %[[VAL_3:[^:]*]]: index) {
60 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
61 // CHECK: %[[VAL_5:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%[[VAL_2]] : index), %[[VAL_1]] {bindc_name = ".tmp.array", uniq_name = ""}
62 // CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_4]]) typeparams %[[VAL_2]] {uniq_name = ".tmp.array"} : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<?x!fir.char<1,?>>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>)
63 // CHECK: %[[VAL_7:.*]] = arith.constant true
64 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
65 // CHECK: fir.do_loop %[[VAL_9:.*]] = %[[VAL_8]] to %[[VAL_1]] step %[[VAL_8]] {
66 // CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_9]]) typeparams %[[VAL_3]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
68 // CHECK: %[[VAL_30:.*]]:2 = hlfir.declare %[[VAL_14:.*]] typeparams %[[VAL_13:.*]] {uniq_name = "tmp"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
69 // CHECK: %[[VAL_31:.*]] = arith.constant false
70 // CHECK: %[[VAL_32:.*]] = fir.undefined tuple<!fir.boxchar<1>, i1>
71 // CHECK: %[[VAL_33:.*]] = fir.insert_value %[[VAL_32]], %[[VAL_31]], [1 : index] : (tuple<!fir.boxchar<1>, i1>, i1) -> tuple<!fir.boxchar<1>, i1>
72 // CHECK: %[[VAL_34:.*]] = fir.insert_value %[[VAL_33]], %[[VAL_30]]#0, [0 : index] : (tuple<!fir.boxchar<1>, i1>, !fir.boxchar<1>) -> tuple<!fir.boxchar<1>, i1>
73 // CHECK: %[[VAL_35:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_9]]) typeparams %[[VAL_2]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
74 // CHECK: hlfir.assign %[[VAL_30]]#0 to %[[VAL_35]] temporary_lhs : !fir.boxchar<1>, !fir.boxchar<1>
76 // CHECK: %[[VAL_36:.*]] = fir.undefined tuple<!fir.box<!fir.array<?x!fir.char<1,?>>>, i1>
77 // CHECK: %[[VAL_37:.*]] = fir.insert_value %[[VAL_36]], %[[VAL_7]], [1 : index] : (tuple<!fir.box<!fir.array<?x!fir.char<1,?>>>, i1>, i1) -> tuple<!fir.box<!fir.array<?x!fir.char<1,?>>>, i1>
78 // CHECK: %[[VAL_38:.*]] = fir.insert_value %[[VAL_37]], %[[VAL_6]]#0, [0 : index] : (tuple<!fir.box<!fir.array<?x!fir.char<1,?>>>, i1>, !fir.box<!fir.array<?x!fir.char<1,?>>>) -> tuple<!fir.box<!fir.array<?x!fir.char<1,?>>>, i1>
81 func.func @derived_transpose(%arg0: !fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, %arg1: index, %arg2: index) {
82 %0 = fir.shape %arg2, %arg1 : (index, index) -> !fir.shape<2>
83 %1 = hlfir.elemental %0 : (!fir.shape<2>) -> !hlfir.expr<?x?x!fir.type<t{field:f32}>> {
84 ^bb0(%arg4: index, %arg5: index):
85 %2 = hlfir.designate %arg0 (%arg4, %arg5) : (!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, index, index) -> !fir.box<!fir.type<t{field:f32}>>
86 %3 = hlfir.as_expr %2 : (!fir.box<!fir.type<t{field:f32}>>) -> !hlfir.expr<!fir.type<t{field:f32}>>
87 hlfir.yield_element %3 : !hlfir.expr<!fir.type<t{field:f32}>>
91 // CHECK-LABEL: func.func @derived_transpose(
92 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>,
93 // CHECK-SAME: %[[VAL_1:[^:]*]]: index,
94 // CHECK-SAME: %[[VAL_2:.*]]: index) {
95 // CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]], %[[VAL_1]] : (index, index) -> !fir.shape<2>
96 // CHECK: %[[VAL_4:.*]] = fir.allocmem !fir.array<?x?x!fir.type<t{field:f32}>>, %[[VAL_2]], %[[VAL_1]] {bindc_name = ".tmp.array", uniq_name = ""}
97 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]](%[[VAL_3]]) {uniq_name = ".tmp.array"} : (!fir.heap<!fir.array<?x?x!fir.type<t{field:f32}>>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, !fir.heap<!fir.array<?x?x!fir.type<t{field:f32}>>>)
98 // CHECK: %[[VAL_6:.*]] = arith.constant true
99 // CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
100 // CHECK: fir.do_loop %[[VAL_8:.*]] = %[[VAL_7]] to %[[VAL_1]] step %[[VAL_7]] {
101 // CHECK: fir.do_loop %[[VAL_9:.*]] = %[[VAL_7]] to %[[VAL_2]] step %[[VAL_7]] {
102 // CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_9]], %[[VAL_8]]) : (!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, index, index) -> !fir.box<!fir.type<t{field:f32}>>
103 // CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_9]], %[[VAL_8]]) : (!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, index, index) -> !fir.ref<!fir.type<t{field:f32}>>
104 // CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_11]] temporary_lhs : !fir.box<!fir.type<t{field:f32}>>, !fir.ref<!fir.type<t{field:f32}>>
107 // CHECK: %[[VAL_12:.*]] = fir.undefined tuple<!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, i1>
108 // CHECK: %[[VAL_13:.*]] = fir.insert_value %[[VAL_12]], %[[VAL_6]], [1 : index] : (tuple<!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, i1>, i1) -> tuple<!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, i1>
109 // CHECK: %[[VAL_14:.*]] = fir.insert_value %[[VAL_13]], %[[VAL_5]]#0, [0 : index] : (tuple<!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, i1>, !fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>) -> tuple<!fir.box<!fir.array<?x?x!fir.type<t{field:f32}>>>, i1>
111 func.func @unordered() {
112 %c10 = arith.constant 10 : index
113 %c20 = arith.constant 20 : index
114 %0 = fir.shape %c10, %c20 : (index, index) -> !fir.shape<2>
115 %3 = hlfir.elemental %0 unordered : (!fir.shape<2>) -> !hlfir.expr<10x20xi32> {
116 ^bb0(%i: index, %j: index):
117 %c0 = arith.constant 0 : i32
118 hlfir.yield_element %c0 : i32
122 // CHECK-LABEL: func.func @unordered() {
123 // CHECK: %[[VAL_0:.*]] = arith.constant 10 : index
124 // CHECK: %[[VAL_1:.*]] = arith.constant 20 : index
125 // CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]], %[[VAL_1]] : (index, index) -> !fir.shape<2>
126 // CHECK: %[[VAL_3:.*]] = fir.allocmem !fir.array<10x20xi32> {bindc_name = ".tmp.array", uniq_name = ""}
127 // CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_2]]) {uniq_name = ".tmp.array"} : (!fir.heap<!fir.array<10x20xi32>>, !fir.shape<2>) -> (!fir.heap<!fir.array<10x20xi32>>, !fir.heap<!fir.array<10x20xi32>>)
128 // CHECK: %[[VAL_5:.*]] = arith.constant true
129 // CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
130 // CHECK: fir.do_loop %[[VAL_7:.*]] = %[[VAL_6]] to %[[VAL_1]] step %[[VAL_6]] unordered {
131 // CHECK: fir.do_loop %[[VAL_8:.*]] = %[[VAL_6]] to %[[VAL_0]] step %[[VAL_6]] unordered {
132 // CHECK: %[[VAL_9:.*]] = arith.constant 0 : i32
133 // CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_8]], %[[VAL_7]]) : (!fir.heap<!fir.array<10x20xi32>>, index, index) -> !fir.ref<i32>
134 // CHECK: hlfir.assign %[[VAL_9]] to %[[VAL_10]] temporary_lhs : i32, !fir.ref<i32>
137 // CHECK: %[[VAL_11:.*]] = fir.undefined tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
138 // CHECK: %[[VAL_12:.*]] = fir.insert_value %[[VAL_11]], %[[VAL_5]], [1 : index] : (tuple<!fir.heap<!fir.array<10x20xi32>>, i1>, i1) -> tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
139 // CHECK: %[[VAL_13:.*]] = fir.insert_value %[[VAL_12]], %[[VAL_4]]#0, [0 : index] : (tuple<!fir.heap<!fir.array<10x20xi32>>, i1>, !fir.heap<!fir.array<10x20xi32>>) -> tuple<!fir.heap<!fir.array<10x20xi32>>, i1>
143 func.func @test_polymorphic(%arg0: !fir.class<!fir.type<_QMtypesTt>> {fir.bindc_name = "x"}, %arg1: !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>> {fir.bindc_name = "y"}, %ex0 : index, %ex1 : index) {
144 %1:2 = hlfir.declare %arg0 {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEx"} : (!fir.class<!fir.type<_QMtypesTt>>) -> (!fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>)
145 %2:2 = hlfir.declare %arg1 {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEy"} : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>) -> (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>)
146 %4 = fir.shape %ex0, %ex1 : (index, index) -> !fir.shape<2>
147 %5 = hlfir.elemental %4 mold %1#0 unordered : (!fir.shape<2>, !fir.class<!fir.type<_QMtypesTt>>) -> !hlfir.expr<?x?x!fir.type<_QMtypesTt>?> {
148 ^bb0(%arg3: index, %arg4: index):
149 %6 = hlfir.designate %2#0 (%arg3, %arg4) : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
150 %7 = hlfir.as_expr %6 : (!fir.class<!fir.type<_QMtypesTt>>) -> !hlfir.expr<!fir.type<_QMtypesTt>?>
151 hlfir.yield_element %7 : !hlfir.expr<!fir.type<_QMtypesTt>?>
155 // CHECK-LABEL: func.func @test_polymorphic(
156 // CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.type<_QMtypesTt>> {fir.bindc_name = "x"},
157 // CHECK-SAME: %[[VAL_1:.*]]: !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>> {fir.bindc_name = "y"},
158 // CHECK-SAME: %[[EX0:.*]]: index,
159 // CHECK-SAME: %[[EX1:.*]]: index) {
160 // CHECK: %[[VAL_4:.*]] = fir.alloca !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
161 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_0]] {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEx"} : (!fir.class<!fir.type<_QMtypesTt>>) -> (!fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>)
162 // CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_1]] {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEy"} : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>) -> (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>)
163 // CHECK: %[[VAL_7:.*]] = fir.shape %[[EX0]], %[[EX1]] : (index, index) -> !fir.shape<2>
164 // CHECK: %[[VAL_8:.*]] = fir.zero_bits !fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>
165 // CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
166 // CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]], %[[VAL_9]] : (index, index) -> !fir.shape<2>
167 // CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_8]](%[[VAL_10]]) : (!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.shape<2>) -> !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
168 // CHECK: fir.store %[[VAL_11]] to %[[VAL_4]] : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
169 // CHECK: %[[VAL_12:.*]] = arith.constant true
170 // CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_4]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = ".tmp.array"} : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>, !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>)
171 // CHECK: %[[RANK:.*]] = arith.constant 2 : i32
172 // CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
173 // CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_5]]#1 : (!fir.class<!fir.type<_QMtypesTt>>) -> !fir.box<none>
174 // CHECK: %[[VAL_17:.*]] = fir.call @_FortranAAllocatableApplyMold(%[[VAL_15]], %[[VAL_16]], %[[RANK]]) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32) -> none
175 // CHECK: %[[VAL_18:.*]] = arith.constant 1 : index
176 // CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
177 // CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
178 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_19]] : (index) -> i32
179 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_18]] : (index) -> i64
180 // CHECK: %[[VAL_23:.*]] = fir.convert %[[EX0]] : (index) -> i64
181 // CHECK: %[[VAL_24:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_20]], %[[VAL_21]], %[[VAL_22]], %[[VAL_23]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
182 // CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
183 // CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
184 // CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_25]] : (index) -> i32
185 // CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_18]] : (index) -> i64
186 // CHECK: %[[VAL_29:.*]] = fir.convert %[[EX1]] : (index) -> i64
187 // CHECK: %[[VAL_30:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_26]], %[[VAL_27]], %[[VAL_28]], %[[VAL_29]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
188 // CHECK: %[[VAL_31:.*]] = fir.address_of(@_QQclX
189 // CHECK: %[[VAL_32:.*]] = arith.constant {{.*}} : index
190 // CHECK: %[[VAL_33:.*]] = arith.constant {{.*}} : i32
191 // CHECK: %[[VAL_34:.*]] = arith.constant false
192 // CHECK: %[[VAL_35:.*]] = fir.absent !fir.box<none>
193 // CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
194 // CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
195 // CHECK: %[[VAL_38:.*]] = fir.call @_FortranAAllocatableAllocate(%[[VAL_36]], %[[VAL_34]], %[[VAL_35]], %[[VAL_37]], %[[VAL_33]]) : (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
196 // CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_13]]#0 : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
197 // CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
198 // CHECK: fir.do_loop %[[VAL_41:.*]] = %[[VAL_40]] to %[[EX1]] step %[[VAL_40]] unordered {
199 // CHECK: fir.do_loop %[[VAL_42:.*]] = %[[VAL_40]] to %[[EX0]] step %[[VAL_40]] unordered {
200 // CHECK: %[[VAL_43:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_42]], %[[VAL_41]]) : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
201 // CHECK: %[[VAL_44:.*]] = arith.constant 0 : index
202 // CHECK: %[[VAL_45:.*]]:3 = fir.box_dims %[[VAL_39]], %[[VAL_44]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
203 // CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
204 // CHECK: %[[VAL_47:.*]]:3 = fir.box_dims %[[VAL_39]], %[[VAL_46]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
205 // CHECK: %[[VAL_48:.*]] = arith.constant 1 : index
206 // CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_45]]#0, %[[VAL_48]] : index
207 // CHECK: %[[VAL_50:.*]] = arith.addi %[[VAL_42]], %[[VAL_49]] : index
208 // CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_47]]#0, %[[VAL_48]] : index
209 // CHECK: %[[VAL_52:.*]] = arith.addi %[[VAL_41]], %[[VAL_51]] : index
210 // CHECK: %[[VAL_53:.*]] = hlfir.designate %[[VAL_39]] (%[[VAL_50]], %[[VAL_52]]) : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
211 // CHECK: hlfir.assign %[[VAL_43]] to %[[VAL_53]] temporary_lhs : !fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>
214 // CHECK: %[[VAL_54:.*]] = fir.undefined tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
215 // CHECK: %[[VAL_55:.*]] = fir.insert_value %[[VAL_54]], %[[VAL_12]], [1 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, i1) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
216 // CHECK: %[[VAL_56:.*]] = fir.insert_value %[[VAL_55]], %[[VAL_39]], [0 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
220 // Test that hlfir.expr mold is properly applied for the second hlfir.elemental.
221 func.func @test_polymorphic_expr(%arg0: !fir.class<!fir.type<_QMtypesTt>> {fir.bindc_name = "x"}, %arg1: !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>> {fir.bindc_name = "y"}, %ex0 : index, %ex1 : index) {
222 %1:2 = hlfir.declare %arg0 {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEx"} : (!fir.class<!fir.type<_QMtypesTt>>) -> (!fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>)
223 %2:2 = hlfir.declare %arg1 {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEy"} : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>) -> (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>)
224 %4 = fir.shape %ex0, %ex1 : (index, index) -> !fir.shape<2>
225 %5 = hlfir.elemental %4 mold %1#0 unordered : (!fir.shape<2>, !fir.class<!fir.type<_QMtypesTt>>) -> !hlfir.expr<?x?x!fir.type<_QMtypesTt>?> {
226 ^bb0(%arg3: index, %arg4: index):
227 %6 = hlfir.designate %2#0 (%arg3, %arg4) : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
228 %7 = hlfir.as_expr %6 : (!fir.class<!fir.type<_QMtypesTt>>) -> !hlfir.expr<!fir.type<_QMtypesTt>?>
229 hlfir.yield_element %7 : !hlfir.expr<!fir.type<_QMtypesTt>?>
231 %8 = hlfir.elemental %4 mold %5 unordered : (!fir.shape<2>, !hlfir.expr<?x?x!fir.type<_QMtypesTt>?>) -> !hlfir.expr<?x?x!fir.type<_QMtypesTt>?> {
232 ^bb0(%arg3: index, %arg4: index):
233 %9 = hlfir.apply %5, %arg3, %arg4 : (!hlfir.expr<?x?x!fir.type<_QMtypesTt>?>, index, index) -> !hlfir.expr<!fir.type<_QMtypesTt>?>
234 hlfir.yield_element %9 : !hlfir.expr<!fir.type<_QMtypesTt>?>
238 // CHECK-LABEL: func.func @test_polymorphic_expr(
239 // CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.type<_QMtypesTt>> {fir.bindc_name = "x"},
240 // CHECK-SAME: %[[VAL_1:.*]]: !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>> {fir.bindc_name = "y"},
241 // CHECK-SAME: %[[VAL_2:.*]]: index,
242 // CHECK-SAME: %[[VAL_3:.*]]: index) {
243 // CHECK: %[[VAL_4:.*]] = fir.alloca !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
244 // CHECK: %[[VAL_5:.*]] = fir.alloca !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
245 // CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]] {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEx"} : (!fir.class<!fir.type<_QMtypesTt>>) -> (!fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>)
246 // CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1]] {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtestEy"} : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>) -> (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>)
247 // CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
248 // CHECK: %[[VAL_9:.*]] = fir.zero_bits !fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>
249 // CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
250 // CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_10]], %[[VAL_10]] : (index, index) -> !fir.shape<2>
251 // CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_9]](%[[VAL_11]]) : (!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.shape<2>) -> !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
252 // CHECK: fir.store %[[VAL_12]] to %[[VAL_5]] : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
253 // CHECK: %[[VAL_13:.*]] = arith.constant true
254 // CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_5]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = ".tmp.array"} : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>, !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>)
255 // CHECK: %[[VAL_15:.*]] = arith.constant 2 : i32
256 // CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
257 // CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]]#1 : (!fir.class<!fir.type<_QMtypesTt>>) -> !fir.box<none>
258 // CHECK: %[[VAL_18:.*]] = fir.call @_FortranAAllocatableApplyMold(%[[VAL_16]], %[[VAL_17]], %[[VAL_15]]) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32) -> none
259 // CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
260 // CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
261 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
262 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (index) -> i32
263 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_19]] : (index) -> i64
264 // CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_2]] : (index) -> i64
265 // CHECK: %[[VAL_25:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_21]], %[[VAL_22]], %[[VAL_23]], %[[VAL_24]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
266 // CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
267 // CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
268 // CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_26]] : (index) -> i32
269 // CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_19]] : (index) -> i64
270 // CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
271 // CHECK: %[[VAL_31:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_27]], %[[VAL_28]], %[[VAL_29]], %[[VAL_30]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
272 // CHECK: %[[VAL_32:.*]] = fir.address_of(@_QQcl
273 // CHECK: %[[VAL_33:.*]] = arith.constant {{.*}} : index
274 // CHECK: %[[VAL_34:.*]] = arith.constant {{.*}} : i32
275 // CHECK: %[[VAL_35:.*]] = arith.constant false
276 // CHECK: %[[VAL_36:.*]] = fir.absent !fir.box<none>
277 // CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
278 // CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_32]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
279 // CHECK: %[[VAL_39:.*]] = fir.call @_FortranAAllocatableAllocate(%[[VAL_37]], %[[VAL_35]], %[[VAL_36]], %[[VAL_38]], %[[VAL_34]]) : (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
280 // CHECK: %[[VAL_40:.*]] = fir.load %[[VAL_14]]#0 : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
281 // CHECK: %[[VAL_41:.*]] = arith.constant 1 : index
282 // CHECK: fir.do_loop %[[VAL_42:.*]] = %[[VAL_41]] to %[[VAL_3]] step %[[VAL_41]] unordered {
283 // CHECK: fir.do_loop %[[VAL_43:.*]] = %[[VAL_41]] to %[[VAL_2]] step %[[VAL_41]] unordered {
284 // CHECK: %[[VAL_44:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_43]], %[[VAL_42]]) : (!fir.class<!fir.array<?x?x!fir.type<_QMtypesTt>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
285 // CHECK: %[[VAL_45:.*]] = arith.constant 0 : index
286 // CHECK: %[[VAL_46:.*]]:3 = fir.box_dims %[[VAL_40]], %[[VAL_45]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
287 // CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
288 // CHECK: %[[VAL_48:.*]]:3 = fir.box_dims %[[VAL_40]], %[[VAL_47]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
289 // CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
290 // CHECK: %[[VAL_50:.*]] = arith.subi %[[VAL_46]]#0, %[[VAL_49]] : index
291 // CHECK: %[[VAL_51:.*]] = arith.addi %[[VAL_43]], %[[VAL_50]] : index
292 // CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_48]]#0, %[[VAL_49]] : index
293 // CHECK: %[[VAL_53:.*]] = arith.addi %[[VAL_42]], %[[VAL_52]] : index
294 // CHECK: %[[VAL_54:.*]] = hlfir.designate %[[VAL_40]] (%[[VAL_51]], %[[VAL_53]]) : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
295 // CHECK: hlfir.assign %[[VAL_44]] to %[[VAL_54]] temporary_lhs : !fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>
298 // CHECK: %[[VAL_55:.*]] = fir.undefined tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
299 // CHECK: %[[VAL_56:.*]] = fir.insert_value %[[VAL_55]], %[[VAL_13]], [1 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, i1) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
300 // CHECK: %[[VAL_57:.*]] = fir.insert_value %[[VAL_56]], %[[VAL_40]], [0 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
301 // CHECK: %[[VAL_58:.*]] = fir.zero_bits !fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>
302 // CHECK: %[[VAL_59:.*]] = arith.constant 0 : index
303 // CHECK: %[[VAL_60:.*]] = fir.shape %[[VAL_59]], %[[VAL_59]] : (index, index) -> !fir.shape<2>
304 // CHECK: %[[VAL_61:.*]] = fir.embox %[[VAL_58]](%[[VAL_60]]) : (!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>, !fir.shape<2>) -> !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>
305 // CHECK: fir.store %[[VAL_61]] to %[[VAL_4]] : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
306 // CHECK: %[[VAL_62:.*]] = arith.constant true
307 // CHECK: %[[VAL_63:.*]]:2 = hlfir.declare %[[VAL_4]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = ".tmp.array"} : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>, !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>)
308 // CHECK: %[[VAL_64:.*]] = arith.constant 2 : i32
309 // CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
310 // CHECK: %[[VAL_66:.*]] = fir.convert %[[VAL_40]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>) -> !fir.box<none>
311 // CHECK: %[[VAL_67:.*]] = fir.call @_FortranAAllocatableApplyMold(%[[VAL_65]], %[[VAL_66]], %[[VAL_64]]) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32) -> none
312 // CHECK: %[[VAL_68:.*]] = arith.constant 1 : index
313 // CHECK: %[[VAL_69:.*]] = arith.constant 0 : index
314 // CHECK: %[[VAL_70:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
315 // CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_69]] : (index) -> i32
316 // CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_68]] : (index) -> i64
317 // CHECK: %[[VAL_73:.*]] = fir.convert %[[VAL_2]] : (index) -> i64
318 // CHECK: %[[VAL_74:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_70]], %[[VAL_71]], %[[VAL_72]], %[[VAL_73]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
319 // CHECK: %[[VAL_75:.*]] = arith.constant 1 : index
320 // CHECK: %[[VAL_76:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
321 // CHECK: %[[VAL_77:.*]] = fir.convert %[[VAL_75]] : (index) -> i32
322 // CHECK: %[[VAL_78:.*]] = fir.convert %[[VAL_68]] : (index) -> i64
323 // CHECK: %[[VAL_79:.*]] = fir.convert %[[VAL_3]] : (index) -> i64
324 // CHECK: %[[VAL_80:.*]] = fir.call @_FortranAAllocatableSetBounds(%[[VAL_76]], %[[VAL_77]], %[[VAL_78]], %[[VAL_79]]) : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> none
325 // CHECK: %[[VAL_81:.*]] = fir.address_of(@_QQcl
326 // CHECK: %[[VAL_82:.*]] = arith.constant {{.*}} : index
327 // CHECK: %[[VAL_83:.*]] = arith.constant {{.*}} : i32
328 // CHECK: %[[VAL_84:.*]] = arith.constant false
329 // CHECK: %[[VAL_85:.*]] = fir.absent !fir.box<none>
330 // CHECK: %[[VAL_86:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>) -> !fir.ref<!fir.box<none>>
331 // CHECK: %[[VAL_87:.*]] = fir.convert %[[VAL_81]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
332 // CHECK: %[[VAL_88:.*]] = fir.call @_FortranAAllocatableAllocate(%[[VAL_86]], %[[VAL_84]], %[[VAL_85]], %[[VAL_87]], %[[VAL_83]]) : (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
333 // CHECK: %[[VAL_89:.*]] = fir.load %[[VAL_63]]#0 : !fir.ref<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>>
334 // CHECK: %[[VAL_90:.*]] = arith.constant 1 : index
335 // CHECK: fir.do_loop %[[VAL_91:.*]] = %[[VAL_90]] to %[[VAL_3]] step %[[VAL_90]] unordered {
336 // CHECK: fir.do_loop %[[VAL_92:.*]] = %[[VAL_90]] to %[[VAL_2]] step %[[VAL_90]] unordered {
337 // CHECK: %[[VAL_93:.*]] = hlfir.designate %[[VAL_40]] (%[[VAL_92]], %[[VAL_91]]) : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
338 // CHECK: %[[VAL_94:.*]] = arith.constant false
339 // CHECK: %[[VAL_95:.*]] = fir.undefined tuple<!fir.class<!fir.type<_QMtypesTt>>, i1>
340 // CHECK: %[[VAL_96:.*]] = fir.insert_value %[[VAL_95]], %[[VAL_94]], [1 : index] : (tuple<!fir.class<!fir.type<_QMtypesTt>>, i1>, i1) -> tuple<!fir.class<!fir.type<_QMtypesTt>>, i1>
341 // CHECK: %[[VAL_97:.*]] = fir.insert_value %[[VAL_96]], %[[VAL_93]], [0 : index] : (tuple<!fir.class<!fir.type<_QMtypesTt>>, i1>, !fir.class<!fir.type<_QMtypesTt>>) -> tuple<!fir.class<!fir.type<_QMtypesTt>>, i1>
342 // CHECK: %[[VAL_98:.*]] = arith.constant 0 : index
343 // CHECK: %[[VAL_99:.*]]:3 = fir.box_dims %[[VAL_89]], %[[VAL_98]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
344 // CHECK: %[[VAL_100:.*]] = arith.constant 1 : index
345 // CHECK: %[[VAL_101:.*]]:3 = fir.box_dims %[[VAL_89]], %[[VAL_100]] : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index) -> (index, index, index)
346 // CHECK: %[[VAL_102:.*]] = arith.constant 1 : index
347 // CHECK: %[[VAL_103:.*]] = arith.subi %[[VAL_99]]#0, %[[VAL_102]] : index
348 // CHECK: %[[VAL_104:.*]] = arith.addi %[[VAL_92]], %[[VAL_103]] : index
349 // CHECK: %[[VAL_105:.*]] = arith.subi %[[VAL_101]]#0, %[[VAL_102]] : index
350 // CHECK: %[[VAL_106:.*]] = arith.addi %[[VAL_91]], %[[VAL_105]] : index
351 // CHECK: %[[VAL_107:.*]] = hlfir.designate %[[VAL_89]] (%[[VAL_104]], %[[VAL_106]]) : (!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, index, index) -> !fir.class<!fir.type<_QMtypesTt>>
352 // CHECK: hlfir.assign %[[VAL_93]] to %[[VAL_107]] temporary_lhs : !fir.class<!fir.type<_QMtypesTt>>, !fir.class<!fir.type<_QMtypesTt>>
355 // CHECK: %[[VAL_108:.*]] = fir.undefined tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
356 // CHECK: %[[VAL_109:.*]] = fir.insert_value %[[VAL_108]], %[[VAL_62]], [1 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, i1) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>
357 // CHECK: %[[VAL_110:.*]] = fir.insert_value %[[VAL_109]], %[[VAL_89]], [0 : index] : (tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>, !fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>) -> tuple<!fir.class<!fir.heap<!fir.array<?x?x!fir.type<_QMtypesTt>>>>, i1>