@@ -624,10 +624,9 @@ class ModifyOperationRewrite : public OperationRewrite {
624624class ReplaceOperationRewrite : public OperationRewrite {
625625public:
626626 ReplaceOperationRewrite (ConversionPatternRewriterImpl &rewriterImpl,
627- Operation *op, const TypeConverter *converter,
628- bool changedResults)
627+ Operation *op, const TypeConverter *converter)
629628 : OperationRewrite(Kind::ReplaceOperation, rewriterImpl, op),
630- converter (converter), changedResults(changedResults) {}
629+ converter (converter) {}
631630
632631 static bool classof (const IRRewrite *rewrite) {
633632 return rewrite->getKind () == Kind::ReplaceOperation;
@@ -641,15 +640,10 @@ class ReplaceOperationRewrite : public OperationRewrite {
641640
642641 const TypeConverter *getConverter () const { return converter; }
643642
644- bool hasChangedResults () const { return changedResults; }
645-
646643private:
647644 // / An optional type converter that can be used to materialize conversions
648645 // / between the new and old values if necessary.
649646 const TypeConverter *converter;
650-
651- // / A boolean flag that indicates whether result types have changed or not.
652- bool changedResults;
653647};
654648
655649class CreateOperationRewrite : public OperationRewrite {
@@ -1383,17 +1377,13 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
13831377 assert (newValues.size () == op->getNumResults ());
13841378 assert (!ignoredOps.contains (op) && " operation was already replaced" );
13851379
1386- // Track if any of the results changed, e.g. erased and replaced with null.
1387- bool resultChanged = false ;
1388-
13891380 // Create mappings for each of the new result values.
13901381 for (auto [newValue, result] : llvm::zip (newValues, op->getResults ())) {
13911382 if (!newValue) {
13921383 // This result was dropped and no replacement value was provided.
13931384 if (unresolvedMaterializations.contains (op)) {
13941385 // Do not create another materializations if we are erasing a
13951386 // materialization.
1396- resultChanged = true ;
13971387 continue ;
13981388 }
13991389
@@ -1406,11 +1396,9 @@ void ConversionPatternRewriterImpl::notifyOpReplaced(Operation *op,
14061396
14071397 // Remap, and check for any result type changes.
14081398 mapping.map (result, newValue);
1409- resultChanged |= (newValue.getType () != result.getType ());
14101399 }
14111400
1412- appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter,
1413- resultChanged);
1401+ appendRewrite<ReplaceOperationRewrite>(op, currentTypeConverter);
14141402
14151403 // Mark this operation and all nested ops as replaced.
14161404 op->walk ([&](Operation *op) { replacedOps.insert (op); });
@@ -2585,7 +2573,7 @@ LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
25852573 for (unsigned i = 0 ; i < rewriterImpl.rewrites .size (); ++i) {
25862574 auto *opReplacement =
25872575 dyn_cast<ReplaceOperationRewrite>(rewriterImpl.rewrites [i].get ());
2588- if (!opReplacement || !opReplacement-> hasChangedResults () )
2576+ if (!opReplacement)
25892577 continue ;
25902578 Operation *op = opReplacement->getOperation ();
25912579 for (OpResult result : op->getResults ()) {
0 commit comments