From c44d521b3054b7d8dc923d13fe7723cfd44807c8 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Mon, 10 Jan 2022 12:40:38 +0100 Subject: [PATCH] [mlir] address post-commit review for D116759 --- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index c3b7163656c6..e5fee6b02b9d 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -464,13 +464,13 @@ void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType, } for (unsigned i = 0, e = indices.size(); i < e; ++i) { - if (llvm::find(operandsToErase, i) == operandsToErase.end()) + if (!llvm::is_contained(operandsToErase, i)) remainingIndices.push_back(indices[i]); } assert(remainingIndices.size() == static_cast(llvm::count( updatedStructIndices, kDynamicIndex)) && - "exected as many index operands as dynamic index attr elements"); + "expected as many index operands as dynamic index attr elements"); result.addTypes(resultType); result.addAttributes(attributes); @@ -522,13 +522,14 @@ LogicalResult verify(LLVM::GEPOp gepOp) { SmallVector indices; SmallVector structSizes; findKnownStructIndices(gepOp.getBase().getType(), indices, &structSizes); - for (unsigned i = 0, e = indices.size(); i < e; ++i) { + DenseIntElementsAttr structIndices = gepOp.getStructIndices(); + for (unsigned i : llvm::seq(0, indices.size())) { unsigned index = indices[i]; // GEP may not be indexing as deep as some structs nested in the type. - if (index >= gepOp.getStructIndices().getNumElements()) + if (index >= structIndices.getNumElements()) continue; - int32_t staticIndex = gepOp.getStructIndices().getValues()[index]; + int32_t staticIndex = structIndices.getValues()[index]; if (staticIndex == LLVM::GEPOp::kDynamicIndex) return gepOp.emitOpError() << "expected index " << index << " indexing a struct to be constant";