Skip to content

Commit

Permalink
[mlir] Remove a not very useful eraseArguments overload
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mogball committed Aug 29, 2022
1 parent e25eb61 commit 27e8ee2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
4 changes: 0 additions & 4 deletions mlir/include/mlir/IR/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/SCF/IR/SCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions mlir/lib/IR/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()); });
Expand Down

0 comments on commit 27e8ee2

Please sign in to comment.