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

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Dec 31 08:21:11 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:

@Hardcode84 Would you have some linalg examples that vectorize into these contiguous gathers? That would be helpful, but no worries if `Vector` is your actual starting point here.

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


More information about the Mlir-commits mailing list