File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1308,7 +1308,7 @@ OpFoldResult arith::IndexCastUIOp::fold(ArrayRef<Attribute> operands) {
1308
1308
// A little hack because we go through int. Otherwise, the size of the
1309
1309
// constant might need to change.
1310
1310
if (auto value = operands[0 ].dyn_cast_or_null <IntegerAttr>())
1311
- return IntegerAttr::get (getType (), value.getUInt ());
1311
+ return IntegerAttr::get (getType (), value.getValue (). getZExtValue ());
1312
1312
1313
1313
return {};
1314
1314
}
Original file line number Diff line number Diff line change @@ -317,6 +317,24 @@ func.func @indexCastUIOfUnsignedExtend(%arg0: i8) -> index {
317
317
return %idx : index
318
318
}
319
319
320
+ // CHECK-LABEL: @indexCastFold
321
+ // CHECK: %[[res:.*]] = arith.constant -2 : index
322
+ // CHECK: return %[[res]]
323
+ func.func @indexCastFold (%arg0: i8 ) -> index {
324
+ %c -2 = arith.constant -2 : i8
325
+ %idx = arith.index_cast %c -2 : i8 to index
326
+ return %idx : index
327
+ }
328
+
329
+ // CHECK-LABEL: @indexCastUIFold
330
+ // CHECK: %[[res:.*]] = arith.constant 254 : index
331
+ // CHECK: return %[[res]]
332
+ func.func @indexCastUIFold (%arg0: i8 ) -> index {
333
+ %c -2 = arith.constant -2 : i8
334
+ %idx = arith.index_castui %c -2 : i8 to index
335
+ return %idx : index
336
+ }
337
+
320
338
// CHECK-LABEL: @signExtendConstant
321
339
// CHECK: %[[cres:.+]] = arith.constant -2 : i16
322
340
// CHECK: return %[[cres]]
You can’t perform that action at this time.
0 commit comments