[Mlir-commits] [mlir] [mlir][vector] Add vector.step operation (PR #96776)

Diego Caballero llvmlistbot at llvm.org
Thu Jul 4 11:12:55 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:

Why do we want to canonicalize the fixed-length variant in the Vector dialect to something else that is not a `vector.step`? I'd suggest that we use `vector.step` as canonical representation for both fixed and scalable versions for consistency. Is there any reason to not doing so?

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


More information about the Mlir-commits mailing list