@@ -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 {
@@ -1383,17 +1377,13 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
1383
1377
assert (newValues.size () == op->getNumResults ());
1384
1378
assert (!ignoredOps.contains (op) && " operation was already replaced" );
1385
1379
1386
- // Track if any of the results changed, e.g. erased and replaced with null.
1387
- bool resultChanged = false ;
1388
-
1389
1380
// Create mappings for each of the new result values.
1390
1381
for (auto [newValue, result] : llvm::zip (newValues, op->getResults ())) {
1391
1382
if (!newValue) {
1392
1383
// This result was dropped and no replacement value was provided.
1393
1384
if (unresolvedMaterializations.contains (op)) {
1394
1385
// Do not create another materializations if we are erasing a
1395
1386
// materialization.
1396
- resultChanged = true ;
1397
1387
continue ;
1398
1388
}
1399
1389
@@ -1406,11 +1396,9 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
1406
1396
1407
1397
// Remap, and check for any result type changes.
1408
1398
mapping.map (result, newValue);
1409
- resultChanged |= (newValue.getType () != result.getType ());
1410
1399
}
1411
1400
1412
- appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter,
1413
- resultChanged);
1401
+ appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter);
1414
1402
1415
1403
// Mark this operation and all nested ops as replaced.
1416
1404
op->walk ([&](Operation *op) { replacedOps.insert (op); });
@@ -2585,7 +2573,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
2585
2573
for (unsigned i = 0 ; i < rewriterImpl.rewrites .size (); ++i) {
2586
2574
auto *opReplacement =
2587
2575
dyn_cast<ReplaceOperationRewrite>(rewriterImpl.rewrites [i].get ());
2588
- if (!opReplacement || !opReplacement-> hasChangedResults () )
2576
+ if (!opReplacement)
2589
2577
continue ;
2590
2578
Operation *op = opReplacement->getOperation ();
2591
2579
for (OpResult result : op->getResults ()) {
0 commit comments