[Mlir-commits] [mlir] [mlir][vector] Canonicalize gathers/scatters with trivial offsets (PR #117939)

Andrzej Warzyński llvmlistbot at llvm.org
Thu Nov 28 11:26:06 PST 2024


================
@@ -5181,6 +5181,19 @@ std::optional<SmallVector<int64_t, 4>> GatherOp::getShapeForUnroll() {
   return llvm::to_vector<4>(getVectorType().getShape());
 }
 
+static LogicalResult isContiguousIndices(Value val) {
+  auto vecType = dyn_cast<VectorType>(val.getType());
+  if (!vecType || vecType.getRank() != 1 || vecType.isScalable())
+    return failure();
+
+  DenseIntElementsAttr elements;
+  if (!matchPattern(val, m_Constant(&elements)))
+    return failure();
+
+  return success(
+      llvm::equal(elements, llvm::seq<int64_t>(0, vecType.getNumElements())));
+}
----------------
banach-space wrote:

Not yet  - the vectorizer looks at the scalar indices _before_ vectorization. However, this patch make me think that we could do better 🤔 Let me look into this!

https://github.com/llvm/llvm-project/pull/117939


More information about the Mlir-commits mailing list