xref: /llvm-project/mlir/test/Dialect/Math/canonicalize_ipowi.mlir (revision 9816edc9f3ce198d41e364dd3467caa839a0c220)
1// RUN: mlir-opt %s -canonicalize | FileCheck %s
2
3// CHECK-LABEL: @ipowi32_fold(
4// CHECK-SAME: %[[result:.+]]: memref<?xi32>
5func.func @ipowi32_fold(%result : memref<?xi32>) {
6// CHECK-DAG: %[[cst0:.+]] = arith.constant 0 : i32
7// CHECK-DAG: %[[cst1:.+]] = arith.constant 1 : i32
8// CHECK-DAG: %[[cst1073741824:.+]] = arith.constant 1073741824 : i32
9// CHECK-DAG: %[[cst_m1:.+]] = arith.constant -1 : i32
10// CHECK-DAG: %[[cst_m27:.+]] = arith.constant -27 : i32
11// CHECK-DAG: %[[i0:.+]] = arith.constant 0 : index
12// CHECK-DAG: %[[i1:.+]] = arith.constant 1 : index
13// CHECK-DAG: %[[i2:.+]] = arith.constant 2 : index
14// CHECK-DAG: %[[i3:.+]] = arith.constant 3 : index
15// CHECK-DAG: %[[i4:.+]] = arith.constant 4 : index
16// CHECK-DAG: %[[i5:.+]] = arith.constant 5 : index
17// CHECK-DAG: %[[i6:.+]] = arith.constant 6 : index
18// CHECK-DAG: %[[i7:.+]] = arith.constant 7 : index
19// CHECK-DAG: %[[i8:.+]] = arith.constant 8 : index
20// CHECK-DAG: %[[i9:.+]] = arith.constant 9 : index
21// CHECK-DAG: %[[i10:.+]] = arith.constant 10 : index
22// CHECK-DAG: %[[i11:.+]] = arith.constant 11 : index
23
24// --- Test power == 0 ---
25  %arg0_base = arith.constant 0 : i32
26  %arg0_power = arith.constant 0 : i32
27  %res0 = math.ipowi %arg0_base, %arg0_power : i32
28  %i0 = arith.constant 0 : index
29  memref.store %res0, %result[%i0] : memref<?xi32>
30// CHECK: memref.store %[[cst1]], %[[result]][%[[i0]]] : memref<?xi32>
31
32  %arg1_base = arith.constant 10 : i32
33  %arg1_power = arith.constant 0 : i32
34  %res1 = math.ipowi %arg1_base, %arg1_power : i32
35  %i1 = arith.constant 1 : index
36  memref.store %res1, %result[%i1] : memref<?xi32>
37// CHECK: memref.store %[[cst1]], %[[result]][%[[i1]]] : memref<?xi32>
38
39  %arg2_base = arith.constant -10 : i32
40  %arg2_power = arith.constant 0 : i32
41  %res2 = math.ipowi %arg2_base, %arg2_power : i32
42  %i2 = arith.constant 2 : index
43  memref.store %res2, %result[%i2] : memref<?xi32>
44// CHECK: memref.store %[[cst1]], %[[result]][%[[i2]]] : memref<?xi32>
45
46// --- Test negative powers ---
47  %arg3_base = arith.constant 0 : i32
48  %arg3_power = arith.constant -1 : i32
49  %res3 = math.ipowi %arg3_base, %arg3_power : i32
50  %i3 = arith.constant 3 : index
51  memref.store %res3, %result[%i3] : memref<?xi32>
52// No folding for ipowi(0, x) for x < 0:
53// CHECK: %[[res3:.+]] = math.ipowi %[[cst0]], %[[cst_m1]] : i32
54// CHECK: memref.store %[[res3]], %[[result]][%[[i3]]] : memref<?xi32>
55
56  %arg4_base = arith.constant 1 : i32
57  %arg4_power = arith.constant -10 : i32
58  %res4 = math.ipowi %arg4_base, %arg4_power : i32
59  %i4 = arith.constant 4 : index
60  memref.store %res4, %result[%i4] : memref<?xi32>
61// CHECK: memref.store %[[cst1]], %[[result]][%[[i4]]] : memref<?xi32>
62
63  %arg5_base = arith.constant 2 : i32
64  %arg5_power = arith.constant -1 : i32
65  %res5 = math.ipowi %arg5_base, %arg5_power : i32
66  %i5 = arith.constant 5 : index
67  memref.store %res5, %result[%i5] : memref<?xi32>
68// CHECK: memref.store %[[cst0]], %[[result]][%[[i5]]] : memref<?xi32>
69
70  %arg6_base = arith.constant -2 : i32
71  %arg6_power = arith.constant -1 : i32
72  %res6 = math.ipowi %arg6_base, %arg6_power : i32
73  %i6 = arith.constant 6 : index
74  memref.store %res6, %result[%i6] : memref<?xi32>
75// CHECK: memref.store %[[cst0]], %[[result]][%[[i6]]] : memref<?xi32>
76
77  %arg7_base = arith.constant -1 : i32
78  %arg7_power = arith.constant -10 : i32
79  %res7 = math.ipowi %arg7_base, %arg7_power : i32
80  %i7 = arith.constant 7 : index
81  memref.store %res7, %result[%i7] : memref<?xi32>
82// CHECK: memref.store %[[cst1]], %[[result]][%[[i7]]] : memref<?xi32>
83
84  %arg8_base = arith.constant -1 : i32
85  %arg8_power = arith.constant -11 : i32
86  %res8 = math.ipowi %arg8_base, %arg8_power : i32
87  %i8 = arith.constant 8 : index
88  memref.store %res8, %result[%i8] : memref<?xi32>
89// CHECK: memref.store %[[cst_m1]], %[[result]][%[[i8]]] : memref<?xi32>
90
91// --- Test positive powers ---
92  %arg9_base = arith.constant -3 : i32
93  %arg9_power = arith.constant 3 : i32
94  %res9 = math.ipowi %arg9_base, %arg9_power : i32
95  %i9 = arith.constant 9 : index
96  memref.store %res9, %result[%i9] : memref<?xi32>
97// CHECK: memref.store %[[cst_m27]], %[[result]][%[[i9]]] : memref<?xi32>
98
99  %arg10_base = arith.constant 2 : i32
100  %arg10_power = arith.constant 30 : i32
101  %res10 = math.ipowi %arg10_base, %arg10_power : i32
102  %i10 = arith.constant 10 : index
103  memref.store %res10, %result[%i10] : memref<?xi32>
104// CHECK: memref.store %[[cst1073741824]], %[[result]][%[[i10]]] : memref<?xi32>
105
106// --- Test vector folding ---
107  %arg11_base = arith.constant 2 : i32
108  %arg11_base_vec = vector.splat %arg11_base : vector<2x2xi32>
109  %arg11_power = arith.constant 30 : i32
110  %arg11_power_vec = vector.splat %arg11_power : vector<2x2xi32>
111  %res11_vec = math.ipowi %arg11_base_vec, %arg11_power_vec : vector<2x2xi32>
112  %i11 = arith.constant 11 : index
113  %res11 = vector.extract %res11_vec[1, 1] : i32 from vector<2x2xi32>
114  memref.store %res11, %result[%i11] : memref<?xi32>
115// CHECK: memref.store %[[cst1073741824]], %[[result]][%[[i11]]] : memref<?xi32>
116
117  return
118}
119
120// CHECK-LABEL: @ipowi64_fold(
121// CHECK-SAME: %[[result:.+]]: memref<?xi64>
122func.func @ipowi64_fold(%result : memref<?xi64>) {
123// CHECK-DAG: %[[cst0:.+]] = arith.constant 0 : i64
124// CHECK-DAG: %[[cst1:.+]] = arith.constant 1 : i64
125// CHECK-DAG: %[[cst1073741824:.+]] = arith.constant 1073741824 : i64
126// CHECK-DAG: %[[cst281474976710656:.+]] = arith.constant 281474976710656 : i64
127// CHECK-DAG: %[[cst_m1:.+]] = arith.constant -1 : i64
128// CHECK-DAG: %[[cst_m27:.+]] = arith.constant -27 : i64
129// CHECK-DAG: %[[i0:.+]] = arith.constant 0 : index
130// CHECK-DAG: %[[i1:.+]] = arith.constant 1 : index
131// CHECK-DAG: %[[i2:.+]] = arith.constant 2 : index
132// CHECK-DAG: %[[i3:.+]] = arith.constant 3 : index
133// CHECK-DAG: %[[i4:.+]] = arith.constant 4 : index
134// CHECK-DAG: %[[i5:.+]] = arith.constant 5 : index
135// CHECK-DAG: %[[i6:.+]] = arith.constant 6 : index
136// CHECK-DAG: %[[i7:.+]] = arith.constant 7 : index
137// CHECK-DAG: %[[i8:.+]] = arith.constant 8 : index
138// CHECK-DAG: %[[i9:.+]] = arith.constant 9 : index
139// CHECK-DAG: %[[i10:.+]] = arith.constant 10 : index
140// CHECK-DAG: %[[i11:.+]] = arith.constant 11 : index
141
142// --- Test power == 0 ---
143  %arg0_base = arith.constant 0 : i64
144  %arg0_power = arith.constant 0 : i64
145  %res0 = math.ipowi %arg0_base, %arg0_power : i64
146  %i0 = arith.constant 0 : index
147  memref.store %res0, %result[%i0] : memref<?xi64>
148// CHECK: memref.store %[[cst1]], %[[result]][%[[i0]]] : memref<?xi64>
149
150  %arg1_base = arith.constant 10 : i64
151  %arg1_power = arith.constant 0 : i64
152  %res1 = math.ipowi %arg1_base, %arg1_power : i64
153  %i1 = arith.constant 1 : index
154  memref.store %res1, %result[%i1] : memref<?xi64>
155// CHECK: memref.store %[[cst1]], %[[result]][%[[i1]]] : memref<?xi64>
156
157  %arg2_base = arith.constant -10 : i64
158  %arg2_power = arith.constant 0 : i64
159  %res2 = math.ipowi %arg2_base, %arg2_power : i64
160  %i2 = arith.constant 2 : index
161  memref.store %res2, %result[%i2] : memref<?xi64>
162// CHECK: memref.store %[[cst1]], %[[result]][%[[i2]]] : memref<?xi64>
163
164// --- Test negative powers ---
165  %arg3_base = arith.constant 0 : i64
166  %arg3_power = arith.constant -1 : i64
167  %res3 = math.ipowi %arg3_base, %arg3_power : i64
168  %i3 = arith.constant 3 : index
169  memref.store %res3, %result[%i3] : memref<?xi64>
170// No folding for ipowi(0, x) for x < 0:
171// CHECK: %[[res3:.+]] = math.ipowi %[[cst0]], %[[cst_m1]] : i64
172// CHECK: memref.store %[[res3]], %[[result]][%[[i3]]] : memref<?xi64>
173
174  %arg4_base = arith.constant 1 : i64
175  %arg4_power = arith.constant -10 : i64
176  %res4 = math.ipowi %arg4_base, %arg4_power : i64
177  %i4 = arith.constant 4 : index
178  memref.store %res4, %result[%i4] : memref<?xi64>
179// CHECK: memref.store %[[cst1]], %[[result]][%[[i4]]] : memref<?xi64>
180
181  %arg5_base = arith.constant 2 : i64
182  %arg5_power = arith.constant -1 : i64
183  %res5 = math.ipowi %arg5_base, %arg5_power : i64
184  %i5 = arith.constant 5 : index
185  memref.store %res5, %result[%i5] : memref<?xi64>
186// CHECK: memref.store %[[cst0]], %[[result]][%[[i5]]] : memref<?xi64>
187
188  %arg6_base = arith.constant -2 : i64
189  %arg6_power = arith.constant -1 : i64
190  %res6 = math.ipowi %arg6_base, %arg6_power : i64
191  %i6 = arith.constant 6 : index
192  memref.store %res6, %result[%i6] : memref<?xi64>
193// CHECK: memref.store %[[cst0]], %[[result]][%[[i6]]] : memref<?xi64>
194
195  %arg7_base = arith.constant -1 : i64
196  %arg7_power = arith.constant -10 : i64
197  %res7 = math.ipowi %arg7_base, %arg7_power : i64
198  %i7 = arith.constant 7 : index
199  memref.store %res7, %result[%i7] : memref<?xi64>
200// CHECK: memref.store %[[cst1]], %[[result]][%[[i7]]] : memref<?xi64>
201
202  %arg8_base = arith.constant -1 : i64
203  %arg8_power = arith.constant -11 : i64
204  %res8 = math.ipowi %arg8_base, %arg8_power : i64
205  %i8 = arith.constant 8 : index
206  memref.store %res8, %result[%i8] : memref<?xi64>
207// CHECK: memref.store %[[cst_m1]], %[[result]][%[[i8]]] : memref<?xi64>
208
209// --- Test positive powers ---
210  %arg9_base = arith.constant -3 : i64
211  %arg9_power = arith.constant 3 : i64
212  %res9 = math.ipowi %arg9_base, %arg9_power : i64
213  %i9 = arith.constant 9 : index
214  memref.store %res9, %result[%i9] : memref<?xi64>
215// CHECK: memref.store %[[cst_m27]], %[[result]][%[[i9]]] : memref<?xi64>
216
217  %arg10_base = arith.constant 2 : i64
218  %arg10_power = arith.constant 30 : i64
219  %res10 = math.ipowi %arg10_base, %arg10_power : i64
220  %i10 = arith.constant 10 : index
221  memref.store %res10, %result[%i10] : memref<?xi64>
222// CHECK: memref.store %[[cst1073741824]], %[[result]][%[[i10]]] : memref<?xi64>
223
224  %arg11_base = arith.constant 2 : i64
225  %arg11_power = arith.constant 48 : i64
226  %res11 = math.ipowi %arg11_base, %arg11_power : i64
227  %i11 = arith.constant 11 : index
228  memref.store %res11, %result[%i11] : memref<?xi64>
229// CHECK: memref.store %[[cst281474976710656]], %[[result]][%[[i11]]] : memref<?xi64>
230
231  return
232}
233
234// CHECK-LABEL: @ipowi16_fold(
235// CHECK-SAME: %[[result:.+]]: memref<?xi16>
236func.func @ipowi16_fold(%result : memref<?xi16>) {
237// CHECK-DAG: %[[cst0:.+]] = arith.constant 0 : i16
238// CHECK-DAG: %[[cst1:.+]] = arith.constant 1 : i16
239// CHECK-DAG: %[[cst16384:.+]] = arith.constant 16384 : i16
240// CHECK-DAG: %[[cst_m1:.+]] = arith.constant -1 : i16
241// CHECK-DAG: %[[cst_m27:.+]] = arith.constant -27 : i16
242// CHECK-DAG: %[[i0:.+]] = arith.constant 0 : index
243// CHECK-DAG: %[[i1:.+]] = arith.constant 1 : index
244// CHECK-DAG: %[[i2:.+]] = arith.constant 2 : index
245// CHECK-DAG: %[[i3:.+]] = arith.constant 3 : index
246// CHECK-DAG: %[[i4:.+]] = arith.constant 4 : index
247// CHECK-DAG: %[[i5:.+]] = arith.constant 5 : index
248// CHECK-DAG: %[[i6:.+]] = arith.constant 6 : index
249// CHECK-DAG: %[[i7:.+]] = arith.constant 7 : index
250// CHECK-DAG: %[[i8:.+]] = arith.constant 8 : index
251// CHECK-DAG: %[[i9:.+]] = arith.constant 9 : index
252// CHECK-DAG: %[[i10:.+]] = arith.constant 10 : index
253
254// --- Test power == 0 ---
255  %arg0_base = arith.constant 0 : i16
256  %arg0_power = arith.constant 0 : i16
257  %res0 = math.ipowi %arg0_base, %arg0_power : i16
258  %i0 = arith.constant 0 : index
259  memref.store %res0, %result[%i0] : memref<?xi16>
260// CHECK: memref.store %[[cst1]], %[[result]][%[[i0]]] : memref<?xi16>
261
262  %arg1_base = arith.constant 10 : i16
263  %arg1_power = arith.constant 0 : i16
264  %res1 = math.ipowi %arg1_base, %arg1_power : i16
265  %i1 = arith.constant 1 : index
266  memref.store %res1, %result[%i1] : memref<?xi16>
267// CHECK: memref.store %[[cst1]], %[[result]][%[[i1]]] : memref<?xi16>
268
269  %arg2_base = arith.constant -10 : i16
270  %arg2_power = arith.constant 0 : i16
271  %res2 = math.ipowi %arg2_base, %arg2_power : i16
272  %i2 = arith.constant 2 : index
273  memref.store %res2, %result[%i2] : memref<?xi16>
274// CHECK: memref.store %[[cst1]], %[[result]][%[[i2]]] : memref<?xi16>
275
276// --- Test negative powers ---
277  %arg3_base = arith.constant 0 : i16
278  %arg3_power = arith.constant -1 : i16
279  %res3 = math.ipowi %arg3_base, %arg3_power : i16
280  %i3 = arith.constant 3 : index
281  memref.store %res3, %result[%i3] : memref<?xi16>
282// No folding for ipowi(0, x) for x < 0:
283// CHECK: %[[res3:.+]] = math.ipowi %[[cst0]], %[[cst_m1]] : i16
284// CHECK: memref.store %[[res3]], %[[result]][%[[i3]]] : memref<?xi16>
285
286  %arg4_base = arith.constant 1 : i16
287  %arg4_power = arith.constant -10 : i16
288  %res4 = math.ipowi %arg4_base, %arg4_power : i16
289  %i4 = arith.constant 4 : index
290  memref.store %res4, %result[%i4] : memref<?xi16>
291// CHECK: memref.store %[[cst1]], %[[result]][%[[i4]]] : memref<?xi16>
292
293  %arg5_base = arith.constant 2 : i16
294  %arg5_power = arith.constant -1 : i16
295  %res5 = math.ipowi %arg5_base, %arg5_power : i16
296  %i5 = arith.constant 5 : index
297  memref.store %res5, %result[%i5] : memref<?xi16>
298// CHECK: memref.store %[[cst0]], %[[result]][%[[i5]]] : memref<?xi16>
299
300  %arg6_base = arith.constant -2 : i16
301  %arg6_power = arith.constant -1 : i16
302  %res6 = math.ipowi %arg6_base, %arg6_power : i16
303  %i6 = arith.constant 6 : index
304  memref.store %res6, %result[%i6] : memref<?xi16>
305// CHECK: memref.store %[[cst0]], %[[result]][%[[i6]]] : memref<?xi16>
306
307  %arg7_base = arith.constant -1 : i16
308  %arg7_power = arith.constant -10 : i16
309  %res7 = math.ipowi %arg7_base, %arg7_power : i16
310  %i7 = arith.constant 7 : index
311  memref.store %res7, %result[%i7] : memref<?xi16>
312// CHECK: memref.store %[[cst1]], %[[result]][%[[i7]]] : memref<?xi16>
313
314  %arg8_base = arith.constant -1 : i16
315  %arg8_power = arith.constant -11 : i16
316  %res8 = math.ipowi %arg8_base, %arg8_power : i16
317  %i8 = arith.constant 8 : index
318  memref.store %res8, %result[%i8] : memref<?xi16>
319// CHECK: memref.store %[[cst_m1]], %[[result]][%[[i8]]] : memref<?xi16>
320
321// --- Test positive powers ---
322  %arg9_base = arith.constant -3 : i16
323  %arg9_power = arith.constant 3 : i16
324  %res9 = math.ipowi %arg9_base, %arg9_power : i16
325  %i9 = arith.constant 9 : index
326  memref.store %res9, %result[%i9] : memref<?xi16>
327// CHECK: memref.store %[[cst_m27]], %[[result]][%[[i9]]] : memref<?xi16>
328
329  %arg10_base = arith.constant 2 : i16
330  %arg10_power = arith.constant 14 : i16
331  %res10 = math.ipowi %arg10_base, %arg10_power : i16
332  %i10 = arith.constant 10 : index
333  memref.store %res10, %result[%i10] : memref<?xi16>
334// CHECK: memref.store %[[cst16384]], %[[result]][%[[i10]]] : memref<?xi16>
335
336  return
337}
338
339// CHECK-LABEL: @ipowi8_fold(
340// CHECK-SAME: %[[result:.+]]: memref<?xi8>
341func.func @ipowi8_fold(%result : memref<?xi8>) {
342// CHECK-DAG: %[[cst0:.+]] = arith.constant 0 : i8
343// CHECK-DAG: %[[cst1:.+]] = arith.constant 1 : i8
344// CHECK-DAG: %[[cst64:.+]] = arith.constant 64 : i8
345// CHECK-DAG: %[[cst_m1:.+]] = arith.constant -1 : i8
346// CHECK-DAG: %[[cst_m27:.+]] = arith.constant -27 : i8
347// CHECK-DAG: %[[i0:.+]] = arith.constant 0 : index
348// CHECK-DAG: %[[i1:.+]] = arith.constant 1 : index
349// CHECK-DAG: %[[i2:.+]] = arith.constant 2 : index
350// CHECK-DAG: %[[i3:.+]] = arith.constant 3 : index
351// CHECK-DAG: %[[i4:.+]] = arith.constant 4 : index
352// CHECK-DAG: %[[i5:.+]] = arith.constant 5 : index
353// CHECK-DAG: %[[i6:.+]] = arith.constant 6 : index
354// CHECK-DAG: %[[i7:.+]] = arith.constant 7 : index
355// CHECK-DAG: %[[i8:.+]] = arith.constant 8 : index
356// CHECK-DAG: %[[i9:.+]] = arith.constant 9 : index
357// CHECK-DAG: %[[i10:.+]] = arith.constant 10 : index
358
359// --- Test power == 0 ---
360  %arg0_base = arith.constant 0 : i8
361  %arg0_power = arith.constant 0 : i8
362  %res0 = math.ipowi %arg0_base, %arg0_power : i8
363  %i0 = arith.constant 0 : index
364  memref.store %res0, %result[%i0] : memref<?xi8>
365// CHECK: memref.store %[[cst1]], %[[result]][%[[i0]]] : memref<?xi8>
366
367  %arg1_base = arith.constant 10 : i8
368  %arg1_power = arith.constant 0 : i8
369  %res1 = math.ipowi %arg1_base, %arg1_power : i8
370  %i1 = arith.constant 1 : index
371  memref.store %res1, %result[%i1] : memref<?xi8>
372// CHECK: memref.store %[[cst1]], %[[result]][%[[i1]]] : memref<?xi8>
373
374  %arg2_base = arith.constant -10 : i8
375  %arg2_power = arith.constant 0 : i8
376  %res2 = math.ipowi %arg2_base, %arg2_power : i8
377  %i2 = arith.constant 2 : index
378  memref.store %res2, %result[%i2] : memref<?xi8>
379// CHECK: memref.store %[[cst1]], %[[result]][%[[i2]]] : memref<?xi8>
380
381// --- Test negative powers ---
382  %arg3_base = arith.constant 0 : i8
383  %arg3_power = arith.constant -1 : i8
384  %res3 = math.ipowi %arg3_base, %arg3_power : i8
385  %i3 = arith.constant 3 : index
386  memref.store %res3, %result[%i3] : memref<?xi8>
387// No folding for ipowi(0, x) for x < 0:
388// CHECK: %[[res3:.+]] = math.ipowi %[[cst0]], %[[cst_m1]] : i8
389// CHECK: memref.store %[[res3]], %[[result]][%[[i3]]] : memref<?xi8>
390
391  %arg4_base = arith.constant 1 : i8
392  %arg4_power = arith.constant -10 : i8
393  %res4 = math.ipowi %arg4_base, %arg4_power : i8
394  %i4 = arith.constant 4 : index
395  memref.store %res4, %result[%i4] : memref<?xi8>
396// CHECK: memref.store %[[cst1]], %[[result]][%[[i4]]] : memref<?xi8>
397
398  %arg5_base = arith.constant 2 : i8
399  %arg5_power = arith.constant -1 : i8
400  %res5 = math.ipowi %arg5_base, %arg5_power : i8
401  %i5 = arith.constant 5 : index
402  memref.store %res5, %result[%i5] : memref<?xi8>
403// CHECK: memref.store %[[cst0]], %[[result]][%[[i5]]] : memref<?xi8>
404
405  %arg6_base = arith.constant -2 : i8
406  %arg6_power = arith.constant -1 : i8
407  %res6 = math.ipowi %arg6_base, %arg6_power : i8
408  %i6 = arith.constant 6 : index
409  memref.store %res6, %result[%i6] : memref<?xi8>
410// CHECK: memref.store %[[cst0]], %[[result]][%[[i6]]] : memref<?xi8>
411
412  %arg7_base = arith.constant -1 : i8
413  %arg7_power = arith.constant -10 : i8
414  %res7 = math.ipowi %arg7_base, %arg7_power : i8
415  %i7 = arith.constant 7 : index
416  memref.store %res7, %result[%i7] : memref<?xi8>
417// CHECK: memref.store %[[cst1]], %[[result]][%[[i7]]] : memref<?xi8>
418
419  %arg8_base = arith.constant -1 : i8
420  %arg8_power = arith.constant -11 : i8
421  %res8 = math.ipowi %arg8_base, %arg8_power : i8
422  %i8 = arith.constant 8 : index
423  memref.store %res8, %result[%i8] : memref<?xi8>
424// CHECK: memref.store %[[cst_m1]], %[[result]][%[[i8]]] : memref<?xi8>
425
426// --- Test positive powers ---
427  %arg9_base = arith.constant -3 : i8
428  %arg9_power = arith.constant 3 : i8
429  %res9 = math.ipowi %arg9_base, %arg9_power : i8
430  %i9 = arith.constant 9 : index
431  memref.store %res9, %result[%i9] : memref<?xi8>
432// CHECK: memref.store %[[cst_m27]], %[[result]][%[[i9]]] : memref<?xi8>
433
434  %arg10_base = arith.constant 2 : i8
435  %arg10_power = arith.constant 6 : i8
436  %res10 = math.ipowi %arg10_base, %arg10_power : i8
437  %i10 = arith.constant 10 : index
438  memref.store %res10, %result[%i10] : memref<?xi8>
439// CHECK: memref.store %[[cst64]], %[[result]][%[[i10]]] : memref<?xi8>
440
441  return
442}
443