1 // Test hlfir.cshift simplification to hlfir.elemental:
2 // RUN: fir-opt --simplify-hlfir-intrinsics %s | FileCheck %s
4 func.func @cshift_vector(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.ref<i32>) -> !hlfir.expr<?xi32>{
5 %res = hlfir.cshift %arg0 %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.ref<i32>) -> !hlfir.expr<?xi32>
6 return %res : !hlfir.expr<?xi32>
8 // CHECK-LABEL: func.func @cshift_vector(
9 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>,
10 // CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>) -> !hlfir.expr<?xi32> {
11 // CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
12 // CHECK: %[[VAL_16:.*]] = arith.constant 0 : i64
13 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
14 // CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
15 // CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
16 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
17 // CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
18 // CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> i64
19 // CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
20 // CHECK: ^bb0(%[[VAL_9:.*]]: index):
21 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (index) -> i64
22 // CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_7]] : i64
23 // CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_11]], %[[VAL_5]] : i64
24 // CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_3]]#1 : (index) -> i64
25 // CHECK: %[[VAL_14:.*]] = arith.remsi %[[VAL_12]], %[[VAL_13]] : i64
26 // CHECK: %[[VAL_15:.*]] = arith.xori %[[VAL_12]], %[[VAL_13]] : i64
27 // CHECK: %[[VAL_17:.*]] = arith.cmpi slt, %[[VAL_15]], %[[VAL_16]] : i64
28 // CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_16]] : i64
29 // CHECK: %[[VAL_19:.*]] = arith.andi %[[VAL_18]], %[[VAL_17]] : i1
30 // CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_14]], %[[VAL_13]] : i64
31 // CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_19]], %[[VAL_20]], %[[VAL_14]] : i64
32 // CHECK: %[[VAL_22:.*]] = arith.addi %[[VAL_21]], %[[VAL_5]] : i64
33 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
34 // CHECK: %[[VAL_25:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
35 // CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_25]]#0, %[[VAL_26]] : index
36 // CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_23]], %[[VAL_27]] : index
37 // CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_28]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
38 // CHECK: %[[VAL_30:.*]] = fir.load %[[VAL_29]] : !fir.ref<i32>
39 // CHECK: hlfir.yield_element %[[VAL_30]] : i32
44 func.func @cshift_2d_by_scalar(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: !fir.ref<i32>) -> !hlfir.expr<?x?xi32> {
45 %dim = arith.constant 2 : i32
46 %res = hlfir.cshift %arg0 %arg1 dim %dim : (!fir.box<!fir.array<?x?xi32>>, !fir.ref<i32>, i32) -> !hlfir.expr<?x?xi32>
47 return %res : !hlfir.expr<?x?xi32>
49 // CHECK-LABEL: func.func @cshift_2d_by_scalar(
50 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>>,
51 // CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>) -> !hlfir.expr<?x?xi32> {
52 // CHECK: %[[VAL_20:.*]] = arith.constant 0 : i64
53 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : i64
54 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
55 // CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
56 // CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
57 // CHECK: %[[VAL_6:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_5]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
58 // CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]]#1, %[[VAL_6]]#1 : (index, index) -> !fir.shape<2>
59 // CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
60 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> i64
61 // CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
62 // CHECK: ^bb0(%[[VAL_12:.*]]: index, %[[VAL_13:.*]]: index):
63 // CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (index) -> i64
64 // CHECK: %[[VAL_15:.*]] = arith.addi %[[VAL_14]], %[[VAL_10]] : i64
65 // CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_15]], %[[VAL_8]] : i64
66 // CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i64
67 // CHECK: %[[VAL_18:.*]] = arith.remsi %[[VAL_16]], %[[VAL_17]] : i64
68 // CHECK: %[[VAL_19:.*]] = arith.xori %[[VAL_16]], %[[VAL_17]] : i64
69 // CHECK: %[[VAL_21:.*]] = arith.cmpi slt, %[[VAL_19]], %[[VAL_20]] : i64
70 // CHECK: %[[VAL_22:.*]] = arith.cmpi ne, %[[VAL_18]], %[[VAL_20]] : i64
71 // CHECK: %[[VAL_23:.*]] = arith.andi %[[VAL_22]], %[[VAL_21]] : i1
72 // CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_18]], %[[VAL_17]] : i64
73 // CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_23]], %[[VAL_24]], %[[VAL_18]] : i64
74 // CHECK: %[[VAL_26:.*]] = arith.addi %[[VAL_25]], %[[VAL_8]] : i64
75 // CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
76 // CHECK: %[[VAL_29:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
77 // CHECK: %[[VAL_31:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_5]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
78 // CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_29]]#0, %[[VAL_5]] : index
79 // CHECK: %[[VAL_34:.*]] = arith.addi %[[VAL_12]], %[[VAL_33]] : index
80 // CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_31]]#0, %[[VAL_5]] : index
81 // CHECK: %[[VAL_36:.*]] = arith.addi %[[VAL_27]], %[[VAL_35]] : index
82 // CHECK: %[[VAL_37:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_34]], %[[VAL_36]]) : (!fir.box<!fir.array<?x?xi32>>, index, index) -> !fir.ref<i32>
83 // CHECK: %[[VAL_38:.*]] = fir.load %[[VAL_37]] : !fir.ref<i32>
84 // CHECK: hlfir.yield_element %[[VAL_38]] : i32
89 func.func @cshift_2d_by_vector(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: !fir.box<!fir.array<?xi32>>) -> !hlfir.expr<?x?xi32> {
90 %dim = arith.constant 2 : i32
91 %res = hlfir.cshift %arg0 %arg1 dim %dim : (!fir.box<!fir.array<?x?xi32>>, !fir.box<!fir.array<?xi32>>, i32) -> !hlfir.expr<?x?xi32>
92 return %res : !hlfir.expr<?x?xi32>
94 // CHECK-LABEL: func.func @cshift_2d_by_vector(
95 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>>,
96 // CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>>) -> !hlfir.expr<?x?xi32> {
97 // CHECK: %[[VAL_26:.*]] = arith.constant 0 : i64
98 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : i64
99 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
100 // CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
101 // CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
102 // CHECK: %[[VAL_6:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_5]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
103 // CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]]#1, %[[VAL_6]]#1 : (index, index) -> !fir.shape<2>
104 // CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
105 // CHECK: ^bb0(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index):
106 // CHECK: %[[VAL_13:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_3]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
107 // CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_13]]#0, %[[VAL_5]] : index
108 // CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_10]], %[[VAL_15]] : index
109 // CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_1]] (%[[VAL_16]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
110 // CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_17]] : !fir.ref<i32>
111 // CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
112 // CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_11]] : (index) -> i64
113 // CHECK: %[[VAL_21:.*]] = arith.addi %[[VAL_20]], %[[VAL_19]] : i64
114 // CHECK: %[[VAL_22:.*]] = arith.subi %[[VAL_21]], %[[VAL_8]] : i64
115 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i64
116 // CHECK: %[[VAL_24:.*]] = arith.remsi %[[VAL_22]], %[[VAL_23]] : i64
117 // CHECK: %[[VAL_25:.*]] = arith.xori %[[VAL_22]], %[[VAL_23]] : i64
118 // CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_25]], %[[VAL_26]] : i64
119 // CHECK: %[[VAL_28:.*]] = arith.cmpi ne, %[[VAL_24]], %[[VAL_26]] : i64
120 // CHECK: %[[VAL_29:.*]] = arith.andi %[[VAL_28]], %[[VAL_27]] : i1
121 // CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_24]], %[[VAL_23]] : i64
122 // CHECK: %[[VAL_31:.*]] = arith.select %[[VAL_29]], %[[VAL_30]], %[[VAL_24]] : i64
123 // CHECK: %[[VAL_32:.*]] = arith.addi %[[VAL_31]], %[[VAL_8]] : i64
124 // CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_32]] : (i64) -> index
125 // CHECK: %[[VAL_35:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
126 // CHECK: %[[VAL_37:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_5]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
127 // CHECK: %[[VAL_39:.*]] = arith.subi %[[VAL_35]]#0, %[[VAL_5]] : index
128 // CHECK: %[[VAL_40:.*]] = arith.addi %[[VAL_10]], %[[VAL_39]] : index
129 // CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_37]]#0, %[[VAL_5]] : index
130 // CHECK: %[[VAL_42:.*]] = arith.addi %[[VAL_33]], %[[VAL_41]] : index
131 // CHECK: %[[VAL_43:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_40]], %[[VAL_42]]) : (!fir.box<!fir.array<?x?xi32>>, index, index) -> !fir.ref<i32>
132 // CHECK: %[[VAL_44:.*]] = fir.load %[[VAL_43]] : !fir.ref<i32>
133 // CHECK: hlfir.yield_element %[[VAL_44]] : i32
138 func.func @cshift_vector_char(%arg0: !fir.box<!fir.array<?x!fir.char<2,?>>>, %arg1: !fir.ref<i32>) -> !hlfir.expr<?x!fir.char<2,?>> {
139 %res = hlfir.cshift %arg0 %arg1 : (!fir.box<!fir.array<?x!fir.char<2,?>>>, !fir.ref<i32>) -> !hlfir.expr<?x!fir.char<2,?>>
140 return %res : !hlfir.expr<?x!fir.char<2,?>>
142 // CHECK-LABEL: func.func @cshift_vector_char(
143 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.char<2,?>>>,
144 // CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>) -> !hlfir.expr<?x!fir.char<2,?>> {
145 // CHECK: %[[VAL_32:.*]] = arith.constant 1 : index
146 // CHECK: %[[VAL_19:.*]] = arith.constant 0 : i64
147 // CHECK: %[[VAL_8:.*]] = arith.constant 1 : i64
148 // CHECK: %[[VAL_6:.*]] = arith.constant 2 : index
149 // CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
150 // CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box<!fir.array<?x!fir.char<2,?>>>, index) -> (index, index, index)
151 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
152 // CHECK: %[[VAL_5:.*]] = fir.box_elesize %[[VAL_0]] : (!fir.box<!fir.array<?x!fir.char<2,?>>>) -> index
153 // CHECK: %[[VAL_7:.*]] = arith.divsi %[[VAL_5]], %[[VAL_6]] : index
154 // CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
155 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i32) -> i64
156 // CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_4]] typeparams %[[VAL_7]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<?x!fir.char<2,?>> {
157 // CHECK: ^bb0(%[[VAL_12:.*]]: index):
158 // CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (index) -> i64
159 // CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_13]], %[[VAL_10]] : i64
160 // CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_8]] : i64
161 // CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_3]]#1 : (index) -> i64
162 // CHECK: %[[VAL_17:.*]] = arith.remsi %[[VAL_15]], %[[VAL_16]] : i64
163 // CHECK: %[[VAL_18:.*]] = arith.xori %[[VAL_15]], %[[VAL_16]] : i64
164 // CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_18]], %[[VAL_19]] : i64
165 // CHECK: %[[VAL_21:.*]] = arith.cmpi ne, %[[VAL_17]], %[[VAL_19]] : i64
166 // CHECK: %[[VAL_22:.*]] = arith.andi %[[VAL_21]], %[[VAL_20]] : i1
167 // CHECK: %[[VAL_23:.*]] = arith.addi %[[VAL_17]], %[[VAL_16]] : i64
168 // CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_22]], %[[VAL_23]], %[[VAL_17]] : i64
169 // CHECK: %[[VAL_25:.*]] = arith.addi %[[VAL_24]], %[[VAL_8]] : i64
170 // CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i64) -> index
171 // CHECK: %[[VAL_27:.*]] = fir.box_elesize %[[VAL_0]] : (!fir.box<!fir.array<?x!fir.char<2,?>>>) -> index
172 // CHECK: %[[VAL_29:.*]] = arith.divsi %[[VAL_27]], %[[VAL_6]] : index
173 // CHECK: %[[VAL_31:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box<!fir.array<?x!fir.char<2,?>>>, index) -> (index, index, index)
174 // CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_31]]#0, %[[VAL_32]] : index
175 // CHECK: %[[VAL_34:.*]] = arith.addi %[[VAL_26]], %[[VAL_33]] : index
176 // CHECK: %[[VAL_35:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_34]]) typeparams %[[VAL_29]] : (!fir.box<!fir.array<?x!fir.char<2,?>>>, index, index) -> !fir.boxchar<2>
177 // CHECK: hlfir.yield_element %[[VAL_35]] : !fir.boxchar<2>
182 func.func @cshift_vector_poly(%arg0: !fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>, %arg1: i32) -> !hlfir.expr<?x!fir.type<_QFFtestTt>?> {
183 %res = hlfir.cshift %arg0 %arg1 : (!fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>, i32) -> !hlfir.expr<?x!fir.type<_QFFtestTt>?>
184 return %res : !hlfir.expr<?x!fir.type<_QFFtestTt>?>
186 // CHECK-LABEL: func.func @cshift_vector_poly(
187 // CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>,
188 // CHECK-SAME: %[[VAL_1:.*]]: i32) -> !hlfir.expr<?x!fir.type<_QFFtestTt>?> {
189 // CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
190 // CHECK: %[[VAL_15:.*]] = arith.constant 0 : i64
191 // CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
192 // CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
193 // CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>, index) -> (index, index, index)
194 // CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
195 // CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_1]] : (i32) -> i64
196 // CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_4]] mold %[[VAL_0]] unordered : (!fir.shape<1>, !fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>) -> !hlfir.expr<?x!fir.type<_QFFtestTt>?> {
197 // CHECK: ^bb0(%[[VAL_8:.*]]: index):
198 // CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (index) -> i64
199 // CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_9]], %[[VAL_6]] : i64
200 // CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_10]], %[[VAL_5]] : i64
201 // CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_3]]#1 : (index) -> i64
202 // CHECK: %[[VAL_13:.*]] = arith.remsi %[[VAL_11]], %[[VAL_12]] : i64
203 // CHECK: %[[VAL_14:.*]] = arith.xori %[[VAL_11]], %[[VAL_12]] : i64
204 // CHECK: %[[VAL_16:.*]] = arith.cmpi slt, %[[VAL_14]], %[[VAL_15]] : i64
205 // CHECK: %[[VAL_17:.*]] = arith.cmpi ne, %[[VAL_13]], %[[VAL_15]] : i64
206 // CHECK: %[[VAL_18:.*]] = arith.andi %[[VAL_17]], %[[VAL_16]] : i1
207 // CHECK: %[[VAL_19:.*]] = arith.addi %[[VAL_13]], %[[VAL_12]] : i64
208 // CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_18]], %[[VAL_19]], %[[VAL_13]] : i64
209 // CHECK: %[[VAL_21:.*]] = arith.addi %[[VAL_20]], %[[VAL_5]] : i64
210 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
211 // CHECK: %[[VAL_24:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>, index) -> (index, index, index)
212 // CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_24]]#0, %[[VAL_25]] : index
213 // CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_22]], %[[VAL_26]] : index
214 // CHECK: %[[VAL_28:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_27]]) : (!fir.class<!fir.array<?x!fir.type<_QFFtestTt>>>, index) -> !fir.class<!fir.type<_QFFtestTt>>
215 // CHECK: hlfir.yield_element %[[VAL_28]] : !fir.class<!fir.type<_QFFtestTt>>
220 // negative: non-constant dim argument
221 func.func @cshift_nonconst_dim(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32, %dim : i32) -> !hlfir.expr<?x?xi32> {
222 %res = hlfir.cshift %arg0 %arg1 dim %dim : (!fir.box<!fir.array<?x?xi32>>, i32, i32) -> !hlfir.expr<?x?xi32>
223 return %res : !hlfir.expr<?x?xi32>
225 // CHECK-LABEL: func.func @cshift_nonconst_dim(
226 // CHECK: hlfir.cshift {{.*}} : (!fir.box<!fir.array<?x?xi32>>, i32, i32) -> !hlfir.expr<?x?xi32>
228 // negative: invalid constant dim argument
229 func.func @cshift_invalid_dim(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32) -> !hlfir.expr<?x?xi32> {
230 %dim = arith.constant 3 : i32
231 %res = hlfir.cshift %arg0 %arg1 dim %dim : (!fir.box<!fir.array<?x?xi32>>, i32, i32) -> !hlfir.expr<?x?xi32>
232 return %res : !hlfir.expr<?x?xi32>
234 // CHECK-LABEL: func.func @cshift_invalid_dim(
235 // CHECK: hlfir.cshift {{.*}} : (!fir.box<!fir.array<?x?xi32>>, i32, i32) -> !hlfir.expr<?x?xi32>
237 // When the input array is 1D, we may assume that DIM==1,
238 // otherwise the program is illegal, and we can do anything
240 func.func @cshift_vector_assumed_dim_1(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: i32) -> !hlfir.expr<?xi32> {
241 %dim = arith.constant 3 : i32
242 %res = hlfir.cshift %arg0 %arg1 dim %dim : (!fir.box<!fir.array<?xi32>>, i32, i32) -> !hlfir.expr<?xi32>
243 return %res : !hlfir.expr<?xi32>
245 // CHECK-LABEL: func.func @cshift_vector_assumed_dim_1(
246 // CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>,
247 // CHECK-SAME: %[[VAL_1:.*]]: i32) -> !hlfir.expr<?xi32> {
248 // CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
249 // CHECK: %[[VAL_16:.*]] = arith.constant 0 : i64
250 // CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
251 // CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
252 // CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
253 // CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]]#1 : (index) -> !fir.shape<1>
254 // CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_1]] : (i32) -> i64
255 // CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
256 // CHECK: ^bb0(%[[VAL_9:.*]]: index):
257 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (index) -> i64
258 // CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_7]] : i64
259 // CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_11]], %[[VAL_6]] : i64
260 // CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
261 // CHECK: %[[VAL_14:.*]] = arith.remsi %[[VAL_12]], %[[VAL_13]] : i64
262 // CHECK: %[[VAL_15:.*]] = arith.xori %[[VAL_12]], %[[VAL_13]] : i64
263 // CHECK: %[[VAL_17:.*]] = arith.cmpi slt, %[[VAL_15]], %[[VAL_16]] : i64
264 // CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_16]] : i64
265 // CHECK: %[[VAL_19:.*]] = arith.andi %[[VAL_18]], %[[VAL_17]] : i1
266 // CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_14]], %[[VAL_13]] : i64
267 // CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_19]], %[[VAL_20]], %[[VAL_14]] : i64
268 // CHECK: %[[VAL_22:.*]] = arith.addi %[[VAL_21]], %[[VAL_6]] : i64
269 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
270 // CHECK: %[[VAL_25:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
271 // CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_25]]#0, %[[VAL_26]] : index
272 // CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_23]], %[[VAL_27]] : index
273 // CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_28]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
274 // CHECK: %[[VAL_30:.*]] = fir.load %[[VAL_29]] : !fir.ref<i32>
275 // CHECK: hlfir.yield_element %[[VAL_30]] : i32