[Mlir-commits] [mlir] [mlir][vector] Add vector.step operation (PR #96776)
Diego Caballero
llvmlistbot at llvm.org
Fri Jul 5 10:49:23 PDT 2024
================
@@ -6316,6 +6316,20 @@ OpFoldResult SplatOp::fold(FoldAdaptor adaptor) {
return SplatElementsAttr::get(getType(), {constOperand});
}
+//===----------------------------------------------------------------------===//
+// StepOp
+//===----------------------------------------------------------------------===//
+
+OpFoldResult StepOp::fold(FoldAdaptor adaptor) {
+ auto resultType = cast<VectorType>(getType());
+ if (resultType.isScalable())
+ return nullptr;
+ SmallVector<APInt> indices;
+ for (unsigned i = 0; i < resultType.getNumElements(); i++)
+ indices.push_back(APInt(/*width=*/64, i));
+ return DenseElementsAttr::get(resultType, indices);
----------------
dcaballe wrote:
Thanks for clarifying! I think consistency is really important to make sure fixed and scalable worlds are aligned when possible and we don't end up with a different set of patterns and problems when we shouldn't. `vector.step` looks like a good abstraction for both fixed and scalable vectors so I'm +1 to removing this canonicalization pattern and let `vector.step` be the canonical representation also for fixed vectors.
https://github.com/llvm/llvm-project/pull/96776
More information about the Mlir-commits
mailing list