[Mlir-commits] [mlir] c44d521 - [mlir] address post-commit review for D116759

Alex Zinenko llvmlistbot at llvm.org
Mon Jan 10 03:41:06 PST 2022


Author: Alex Zinenko
Date: 2022-01-10T12:40:58+01:00
New Revision: c44d521b3054b7d8dc923d13fe7723cfd44807c8

URL: https://github.com/llvm/llvm-project/commit/c44d521b3054b7d8dc923d13fe7723cfd44807c8
DIFF: https://github.com/llvm/llvm-project/commit/c44d521b3054b7d8dc923d13fe7723cfd44807c8.diff

LOG: [mlir] address post-commit review for D116759

Added: 
    

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index c3b7163656c6d..e5fee6b02b9d0 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<size_t>(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<unsigned> indices;
   SmallVector<unsigned> 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<unsigned>(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<int32_t>()[index];
+    int32_t staticIndex = structIndices.getValues<int32_t>()[index];
     if (staticIndex == LLVM::GEPOp::kDynamicIndex)
       return gepOp.emitOpError() << "expected index " << index
                                  << " indexing a struct to be constant";


        


More information about the Mlir-commits mailing list