Issue 237545
Summary [mlir][vector] Clarify transfer element type requirements: verifier and documentation disagree
Labels mlir
Assignees
Reporter meinie0826
    The documentation and verifier disagree about whether vector transfers may use different base element types.

Both `vector.transfer_read` and `vector.transfer_write` document a transfer between a MemRef/Tensor and a vector of the **same base elemental type**. However, the shared `verifyTransferOp` checks bitwidth divisibility without requiring those base element types to match.

For example, this is accepted by `mlir-opt` without passes (exit code 0):

```python
func.func @read(%a: memref<8xi32>, %pad: i32) -> vector<4xi64> {
  %c0 = arith.constant 0 : index
  %r = vector.transfer_read %a[%c0], %pad {in_bounds = [true]} : memref<8xi32>, vector<4xi64>
  return %r : vector<4xi64>
}
```

Here the source and padding have element type `i32`, but the result has element type `i64`. Verifier acceptance alone does not establish whether this is intended to represent a conversion, a bit reinterpretation, or unsupported IR.

Reproduced with an assertions-enabled local build at `3a73d0e8ff84f4ae36307823fb036ef7821c9788`. The relevant documentation and bitwidth checks are also present in upstream main at `ac9879eef5db5a4d6bb104d6e94272e8a1905355` (source inspection, not a separate build):

- [Read documentation](https://github.com/llvm/llvm-project/blob/ac9879eef5db5a4d6bb104d6e94272e8a1905355/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td#L1332)
- [Write documentation](https://github.com/llvm/llvm-project/blob/ac9879eef5db5a4d6bb104d6e94272e8a1905355/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td#L1586)
- [Shared verifier](https://github.com/llvm/llvm-project/blob/ac9879eef5db5a4d6bb104d6e94272e8a1905355/mlir/lib/Dialect/Vector/IR/VectorOps.cpp#L5171-L5225)

Could we clarify the intended contract and align the verifier/documentation accordingly? If matching base element types are required, the verifier should reject this example. If differing types are supported, their semantics and applicable restrictions need to be documented, including padding, masks and indexing.

Raised following [review on #236320](https://github.com/llvm/llvm-project/pull/236320#discussion_r4431331655), separately from the Mem2Reg optimization. Related closed issue: #108360 reported a lowering crash with an `f32`/`f64` transfer; this issue concerns the underlying verifier/documentation contract rather than that specific crash.

AI assistance was used to investigate the example and prepare this issue description.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to