@@ -1218,7 +1218,12 @@ class CopySimplification final : public OpRewritePattern<T> {
1218
1218
todo.push_back (ext.getIn ());
1219
1219
else if (auto ext = len.getDefiningOp <arith::ExtSIOp>())
1220
1220
todo.push_back (ext.getIn ());
1221
- else if (auto ext = len.getDefiningOp <arith::IndexCastOp>())
1221
+ else if (auto ext = len.getDefiningOp <arith::TruncIOp>()) {
1222
+ if (APInt (64 , width).isPowerOf2 () &&
1223
+ ext.getType ().getIntOrFloatBitWidth () >
1224
+ APInt (64 , width).nearestLogBase2 ())
1225
+ todo.push_back (ext.getIn ());
1226
+ } else if (auto ext = len.getDefiningOp <arith::IndexCastOp>())
1222
1227
todo.push_back (ext.getIn ());
1223
1228
else if (auto mul = len.getDefiningOp <arith::MulIOp>()) {
1224
1229
todo.push_back (mul.getLhs ());
@@ -1314,7 +1319,12 @@ class SetSimplification final : public OpRewritePattern<T> {
1314
1319
todo.push_back (ext.getIn ());
1315
1320
else if (auto ext = len.getDefiningOp <arith::ExtSIOp>())
1316
1321
todo.push_back (ext.getIn ());
1317
- else if (auto ext = len.getDefiningOp <arith::IndexCastOp>())
1322
+ else if (auto ext = len.getDefiningOp <arith::TruncIOp>()) {
1323
+ if (APInt (64 , width).isPowerOf2 () &&
1324
+ ext.getType ().getIntOrFloatBitWidth () >
1325
+ APInt (64 , width).nearestLogBase2 ())
1326
+ todo.push_back (ext.getIn ());
1327
+ } else if (auto ext = len.getDefiningOp <arith::IndexCastOp>())
1318
1328
todo.push_back (ext.getIn ());
1319
1329
else if (auto mul = len.getDefiningOp <arith::MulIOp>()) {
1320
1330
todo.push_back (mul.getLhs ());
0 commit comments