[mlir] Use llvm::is_contained instead of llvm::all_of (NFC) (#145845)

llvm::is_contained is shorter than llvm::all_of plus a lambda.
This commit is contained in:
Kazu Hirata
2025-06-26 08:41:26 -07:00
committed by GitHub
parent 3d5903c4d8
commit abc2c3a538
4 changed files with 6 additions and 10 deletions

View File

@@ -922,8 +922,7 @@ static bool isLoopInvariantIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
return llvm::all_of(block->getArguments(),
[&val](Value v) { return (v != val); });
return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");
@@ -982,8 +981,7 @@ static bool isContiguousLoadIdx(LinalgOp &linalgOp, Value &val,
// TODO: We could try analysing the corresponding affine map here.
auto *block = linalgOp.getBlock();
if (isa<BlockArgument>(val))
return llvm::all_of(block->getArguments(),
[&val](Value v) { return (v != val); });
return !llvm::is_contained(block->getArguments(), val);
Operation *defOp = val.getDefiningOp();
assert(defOp && "This is neither a block argument nor an operation result");

View File

@@ -929,7 +929,7 @@ std::pair<Operation *, Value> sparse_tensor::genCoIteration(
ivs.push_back(uniIdx);
// Ensures all operands are valid.
assert(llvm::all_of(ivs, [](Value v) { return v != nullptr; }));
assert(!llvm::is_contained(ivs, nullptr));
TypeRange types = ValueRange(ivs).getTypes();
auto whileOp = builder.create<scf::WhileOp>(loc, types, ivs);

View File

@@ -321,8 +321,7 @@ Value vector::createReadOrMaskedRead(OpBuilder &builder, Location loc,
ArrayRef<int64_t> inputVectorSizes,
Value padValue,
bool useInBoundsInsteadOfMasking) {
assert(llvm::none_of(inputVectorSizes,
[](int64_t s) { return s == ShapedType::kDynamic; }) &&
assert(!llvm::is_contained(inputVectorSizes, ShapedType::kDynamic) &&
"invalid input vector sizes");
auto sourceShapedType = cast<ShapedType>(source.getType());
auto sourceShape = sourceShapedType.getShape();

View File

@@ -253,9 +253,8 @@ void DefGen::createParentWithTraits() {
// method.
std::string opAsmInterfaceTraitName =
strfmt("::mlir::OpAsm{0}Interface::Trait", defType);
if (def.genMnemonicAlias() && llvm::none_of(traitNames, [&](auto &traitName) {
return traitName == opAsmInterfaceTraitName;
})) {
if (def.genMnemonicAlias() &&
!llvm::is_contained(traitNames, opAsmInterfaceTraitName)) {
defParent.addTemplateParam(opAsmInterfaceTraitName);
}
defCls.addParent(std::move(defParent));