[Mlir-commits] [mlir] 27e8ee2 - [mlir] Remove a not very useful `eraseArguments` overload
Jeff Niu
llvmlistbot at llvm.org
Mon Aug 29 16:07:44 PDT 2022
Author: Jeff Niu
Date: 2022-08-29T16:07:32-07:00
New Revision: 27e8ee208cb2142514ee2e3ab342dafaf6374f9e
URL: https://github.com/llvm/llvm-project/commit/27e8ee208cb2142514ee2e3ab342dafaf6374f9e
DIFF: https://github.com/llvm/llvm-project/commit/27e8ee208cb2142514ee2e3ab342dafaf6374f9e.diff
LOG: [mlir] Remove a not very useful `eraseArguments` overload
This overload just wraps a bitvector, and in most cases a bitvector
could be used directly instead of a list.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D132896
Added:
Modified:
mlir/include/mlir/IR/Block.h
mlir/lib/Dialect/SCF/IR/SCF.cpp
mlir/lib/IR/Block.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 1e4e51cc8190f..723dda3f7208c 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -107,10 +107,6 @@ class Block : public IRObjectWithUseList<BlockOperand>,
void eraseArgument(unsigned index);
/// Erases 'num' arguments from the index 'start'.
void eraseArguments(unsigned start, unsigned num);
- /// Erases the arguments listed in `argIndices` and removes them from the
- /// argument list.
- /// `argIndices` is allowed to have duplicates and can be in any order.
- void eraseArguments(ArrayRef<unsigned> argIndices);
/// Erases the arguments that have their corresponding bit set in
/// `eraseIndices` and removes them from the argument list.
void eraseArguments(const BitVector &eraseIndices);
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 019829597f12d..2de15969288d2 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -3219,21 +3219,21 @@ struct WhileUnusedArg : public OpRewritePattern<WhileOp> {
// Collect results mapping, new terminator args and new result types.
SmallVector<Value> newYields;
SmallVector<Value> newInits;
- SmallVector<unsigned> argsToErase;
+ llvm::BitVector argsToErase(op.getBeforeArguments().size());
for (const auto &it : llvm::enumerate(llvm::zip(
op.getBeforeArguments(), yield.getOperands(), op.getInits()))) {
Value beforeArg = std::get<0>(it.value());
Value yieldValue = std::get<1>(it.value());
Value initValue = std::get<2>(it.value());
if (beforeArg.use_empty()) {
- argsToErase.push_back(it.index());
+ argsToErase.set(it.index());
} else {
newYields.emplace_back(yieldValue);
newInits.emplace_back(initValue);
}
}
- if (argsToErase.empty())
+ if (argsToErase.none())
return failure();
rewriter.startRootUpdate(op);
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index cc84b0d4884f8..cedbe19d8f0ed 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -195,13 +195,6 @@ void Block::eraseArguments(unsigned start, unsigned num) {
arg.setArgNumber(start++);
}
-void Block::eraseArguments(ArrayRef<unsigned> argIndices) {
- BitVector eraseIndices(getNumArguments());
- for (unsigned i : argIndices)
- eraseIndices.set(i);
- eraseArguments(eraseIndices);
-}
-
void Block::eraseArguments(const BitVector &eraseIndices) {
eraseArguments(
[&](BlockArgument arg) { return eraseIndices.test(arg.getArgNumber()); });
More information about the Mlir-commits
mailing list