replaceAllUsesExcept(Value newValue,
const SmallPtrSetImpl<Operation *> &exceptions) const;
+ /// Replace all uses of 'this' value with 'newValue', updating anything in the
+ /// IR that uses 'this' to use the other value instead except if the user is
+ /// 'exceptedUser'.
+ void replaceAllUsesExcept(Value newValue, Operation *exceptedUser) const;
+
/// Replace all uses of 'this' value with 'newValue' if the given callback
/// returns true.
void replaceUsesWithIf(Value newValue,
applyOperands.push_back(iv);
applyOperands.append(symbolOperands.begin(), symbolOperands.end());
auto apply = builder.create<AffineApplyOp>(op.getLoc(), map, applyOperands);
- iv.replaceAllUsesExcept(apply, SmallPtrSet<Operation *, 1>{apply});
+ iv.replaceAllUsesExcept(apply, apply);
}
SmallVector<int64_t, 8> newSteps(op.getNumDims(), 1);
AffineMap ivMap = AffineMap::get(origLbMap.getNumDims() + 1,
origLbMap.getNumSymbols(), newIVExpr);
Operation *newIV = opBuilder.create<AffineApplyOp>(loc, ivMap, lbOperands);
- op.getInductionVar().replaceAllUsesExcept(newIV->getResult(0),
- SmallPtrSet<Operation *, 1>{newIV});
+ op.getInductionVar().replaceAllUsesExcept(newIV->getResult(0), newIV);
}
namespace {
AffineApplyOp applyOp = builder.create<AffineApplyOp>(
indexOp.getLoc(), index + offset,
ValueRange{indexOp.getResult(), loopRanges[indexOp.dim()].offset});
- indexOp.getResult().replaceAllUsesExcept(
- applyOp, SmallPtrSet<Operation *, 1>{applyOp});
+ indexOp.getResult().replaceAllUsesExcept(applyOp, applyOp);
}
}
AffineApplyOp applyOp = b.create<AffineApplyOp>(
indexOp.getLoc(), index + iv,
ValueRange{indexOp.getResult(), ivs[rangeIndex->second]});
- indexOp.getResult().replaceAllUsesExcept(
- applyOp.getResult(), SmallPtrSet<Operation *, 1>{applyOp});
+ indexOp.getResult().replaceAllUsesExcept(applyOp, applyOp);
}
}
Value inner_index = std::get<0>(ivs);
AddIOp newIndex =
b.create<AddIOp>(op.getLoc(), std::get<0>(ivs), std::get<1>(ivs));
- inner_index.replaceAllUsesExcept(
- newIndex, SmallPtrSet<Operation *, 1>{newIndex.getOperation()});
+ inner_index.replaceAllUsesExcept(newIndex, newIndex);
}
op.erase();
/// listed in 'exceptions' .
void Value::replaceAllUsesExcept(
Value newValue, const SmallPtrSetImpl<Operation *> &exceptions) const {
- for (auto &use : llvm::make_early_inc_range(getUses())) {
+ for (OpOperand &use : llvm::make_early_inc_range(getUses())) {
if (exceptions.count(use.getOwner()) == 0)
use.set(newValue);
}
}
+/// Replace all uses of 'this' value with 'newValue', updating anything in the
+/// IR that uses 'this' to use the other value instead except if the user is
+/// 'exceptedUser'.
+void Value::replaceAllUsesExcept(Value newValue,
+ Operation *exceptedUser) const {
+ for (OpOperand &use : llvm::make_early_inc_range(getUses())) {
+ if (use.getOwner() != exceptedUser)
+ use.set(newValue);
+ }
+}
+
/// Replace all uses of 'this' value with 'newValue' if the given callback
/// returns true.
void Value::replaceUsesWithIf(Value newValue,