[Mlir-commits] [mlir] 339753d - [mlir][vector][NFC] `isDisjointTransferIndices`: Use `getConstantIntValue` (#65931)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 11 04:30:40 PDT 2023


Author: Matthias Springer
Date: 2023-09-11T13:30:36+02:00
New Revision: 339753de12294b6c8f2806ae77f0ebcd4df9500d

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

LOG: [mlir][vector][NFC] `isDisjointTransferIndices`: Use `getConstantIntValue` (#65931)

Use `getConstantIntValue` instead of matching for `arith::ConstantOp`.

Added: 
    

Modified: 
    mlir/lib/Dialect/Vector/IR/VectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 1222542ee39fd6a..14dd8d53b193dd7 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -172,24 +172,21 @@ bool mlir::vector::isDisjointTransferIndices(
     return false;
   unsigned rankOffset = transferA.getLeadingShapedRank();
   for (unsigned i = 0, e = transferA.indices().size(); i < e; i++) {
-    auto indexA = transferA.indices()[i].getDefiningOp<arith::ConstantOp>();
-    auto indexB = transferB.indices()[i].getDefiningOp<arith::ConstantOp>();
+    auto indexA = getConstantIntValue(transferA.indices()[i]);
+    auto indexB = getConstantIntValue(transferB.indices()[i]);
     // If any of the indices are dynamic we cannot prove anything.
-    if (!indexA || !indexB)
+    if (!indexA.has_value() || !indexB.has_value())
       continue;
 
     if (i < rankOffset) {
       // For leading dimensions, if we can prove that index are 
diff erent we
       // know we are accessing disjoint slices.
-      if (llvm::cast<IntegerAttr>(indexA.getValue()).getInt() !=
-          llvm::cast<IntegerAttr>(indexB.getValue()).getInt())
+      if (*indexA != *indexB)
         return true;
     } else {
       // For this dimension, we slice a part of the memref we need to make sure
       // the intervals accessed don't overlap.
-      int64_t distance =
-          std::abs(llvm::cast<IntegerAttr>(indexA.getValue()).getInt() -
-                   llvm::cast<IntegerAttr>(indexB.getValue()).getInt());
+      int64_t distance = std::abs(*indexA - *indexB);
       if (distance >= transferA.getVectorType().getDimSize(i - rankOffset))
         return true;
     }


        


More information about the Mlir-commits mailing list