[Mlir-commits] [mlir] [mlir][vector] Allow signless integer element types in `vector.step` (PR #205142)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Jun 22 16:53:05 PDT 2026
================
@@ -3019,27 +3019,38 @@ def Vector_ScanOp :
// VectorStepOp
//===----------------------------------------------------------------------===//
+// Allowed element type for `vector.step`: `index`, or a signless integer of at
+// least 8 bits.
+def VectorStepElementType : Type<
+ CPred<"::llvm::isa<::mlir::IndexType>($_self) || ($_self.isSignlessInteger() && $_self.getIntOrFloatBitWidth() >= 8)">,
+ "index or signless integer of at least 8 bits">;
+
def Vector_StepOp : Vector_Op<"step", [
Pure,
DeclareOpInterfaceMethods<VectorUnrollOpInterface>,
DeclareOpInterfaceMethods<InferIntRangeInterface, ["inferResultRanges"]>
]> {
let summary = "A linear sequence of values from 0 to N";
let description = [{
- A `step` operation produces an index vector, i.e. a 1-D vector of values of
- index type that represents a linear sequence from 0 to N-1, where N is the
- number of elements in the `result` vector.
+ A `step` operation produces a 1-D vector representing a linear sequence from
+ 0 to N-1, where N is the number of elements in the `result` vector.
+
+ The result element type must be `index` or a signless integer of at least 8
+ bits. If the sequence value exceeds the allowed limit for the element type
+ then the result for that lane is truncated.
Supports fixed-width and scalable vectors.
Examples:
```mlir
- %0 = vector.step : vector<4xindex> ; [0, 1, 2, 3]
- %1 = vector.step : vector<[4]xindex> ; [0, 1, .., <vscale * 4 - 1>]
+ %0 = vector.step : vector<4xindex> ; [0, 1, 2, 3]
+ %1 = vector.step : vector<4xi32> ; [0, 1, 2, 3]
+ %2 = vector.step : vector<258xi8> ; [0, 1, .., 255, 0, 1]
+ %3 = vector.step : vector<[4]xindex> ; [0, 1, .., <vscale * 4 - 1>]
----------------
kuhar wrote:
mlir uses `//` for inline comments
https://github.com/llvm/llvm-project/pull/205142
More information about the Mlir-commits
mailing list