@@ -624,10 +624,9 @@ class ModifyOperationRewrite : public OperationRewrite {
624
624
class ReplaceOperationRewrite : public OperationRewrite {
625
625
public:
626
626
ReplaceOperationRewrite (ConversionPatternRewriterImpl &rewriterImpl,
627
- Operation *op, const TypeConverter *converter,
628
- bool changedResults)
627
+ Operation *op, const TypeConverter *converter)
629
628
: OperationRewrite(Kind::ReplaceOperation, rewriterImpl, op),
630
- converter (converter), changedResults(changedResults) {}
629
+ converter (converter) {}
631
630
632
631
static bool classof (const IRRewrite *rewrite) {
633
632
return rewrite->getKind () == Kind::ReplaceOperation;
@@ -641,15 +640,10 @@ class ReplaceOperationRewrite : public OperationRewrite {
641
640
642
641
const TypeConverter *getConverter () const { return converter; }
643
642
644
- bool hasChangedResults () const { return changedResults; }
645
-
646
643
private:
647
644
// / An optional type converter that can be used to materialize conversions
648
645
// / between the new and old values if necessary.
649
646
const TypeConverter *converter;
650
-
651
- // / A boolean flag that indicates whether result types have changed or not.
652
- bool changedResults;
653
647
};
654
648
655
649
class CreateOperationRewrite : public OperationRewrite {
@@ -1377,17 +1371,13 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
1377
1371
assert (newValues.size () == op->getNumResults ());
1378
1372
assert (!ignoredOps.contains (op) && " operation was already replaced" );
1379
1373
1380
- // Track if any of the results changed, e.g. erased and replaced with null.
1381
- bool resultChanged = false ;
1382
-
1383
1374
// Create mappings for each of the new result values.
1384
1375
for (auto [newValue, result] : llvm::zip (newValues, op->getResults ())) {
1385
1376
if (!newValue) {
1386
1377
// This result was dropped and no replacement value was provided.
1387
1378
if (unresolvedMaterializations.contains (op)) {
1388
1379
// Do not create another materializations if we are erasing a
1389
1380
// materialization.
1390
- resultChanged = true ;
1391
1381
continue ;
1392
1382
}
1393
1383
@@ -1400,11 +1390,9 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
1400
1390
1401
1391
// Remap, and check for any result type changes.
1402
1392
mapping.map (result, newValue);
1403
- resultChanged |= (newValue.getType () != result.getType ());
1404
1393
}
1405
1394
1406
- appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter,
1407
- resultChanged);
1395
+ appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter);
1408
1396
1409
1397
// Mark this operation and all nested ops as replaced.
1410
1398
op->walk ([&](Operation *op) { replacedOps.insert (op); });
@@ -2507,7 +2495,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
2507
2495
for (unsigned i = 0 ; i < rewriterImpl.rewrites .size (); ++i) {
2508
2496
auto *opReplacement =
2509
2497
dyn_cast<ReplaceOperationRewrite>(rewriterImpl.rewrites [i].get ());
2510
- if (!opReplacement || !opReplacement-> hasChangedResults () )
2498
+ if (!opReplacement)
2511
2499
continue ;
2512
2500
Operation *op = opReplacement->getOperation ();
2513
2501
for (OpResult result : op->getResults ()) {
0 commit comments