[Mlir-commits] [mlir] [mlir][vector] Allow signless integer element types in `vector.step` (PR #205142)

Andrzej WarzyƄski llvmlistbot at llvm.org
Wed Jun 24 07:15:57 PDT 2026


================
@@ -1756,6 +1756,25 @@ func.func @step() -> vector<4xindex> {
   return %0 : vector<4xindex>
 }
 
+// CHECK-LABEL: @step_i8
+// CHECK: %[[CST:.+]] = arith.constant dense<[0, 1, 2, 3]> : vector<4xi8>
+// CHECK: return %[[CST]] : vector<4xi8>
+func.func @step_i8() -> vector<4xi8> {
+  %0 = vector.step : vector<4xi8>
+  return %0 : vector<4xi8>
+}
+
+// The sequence wraps past the i8 limit, so lane values are truncated. The
+// constant is printed as a hex blob ending in `...FEFF0001`: after 255 (`FF`)
+// the values restart at 0 (`00`) and 1 (`01`).
+// CHECK-LABEL: @step_i8_truncate
+// CHECK: %[[CST:.+]] = arith.constant dense<"0x0001{{.*}}FEFF0001"> : vector<258xi8>
+// CHECK: return %[[CST]] : vector<258xi8>
+func.func @step_i8_truncate() -> vector<258xi8> {
+  %0 = vector.step : vector<258xi8>
+  return %0 : vector<258xi8>
+}
+
----------------
banach-space wrote:

This is effectively testing `StepToArithConstantOpRewrite` rather than convert-vector-to-llvm (there are no LLVM ops in the output). To test it as a standalone pattern, you will need to introduce a new TD op, similar to e.g. https://github.com/llvm/llvm-project/blob/0b5c006208cf7b0fee3709f468152e7de81607ef/mlir/include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.td?plain=1#L349-L361

Would you be able to do that?

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


More information about the Mlir-commits mailing list