Issue 239738
Summary [mlir][VectorToLLVM] N-D `vector.shuffle` poison lane becomes `llvm.extractvalue` position -1
Labels mlir
Assignees
Reporter pingshiyu
    Reproduced with the optimized LLVM Git `main` build at commit fb288ec4774f8664b165f6e302db5be8b30a41da, dated 04/Nov/2026.

```mlir
func.func @test(%x: vector<5x1xi32>) -> i32 {
  %s = vector.shuffle %x, %x[-1] : vector<5x1xi32>, vector<5x1xi32>
  %e = vector.extract %s[0, 0] : i32 from vector<1x1xi32>
  return %e : i32
}
```

```console
mlir-opt repro.mlir -o /dev/null
mlir-opt repro.mlir --convert-vector-to-llvm -o /dev/null
```

The program is valid, but `--convert-vector-to-llvm` fails with:

```text
error: 'llvm.extractvalue' op position out of bounds: -1
note: see current operation: ... "llvm.extractvalue" ... position = array<i64: -1>
```

`-1` is a legal poison entry in a `vector.shuffle` mask. The converted lane should be poison (based on semantics from the documentation https://mlir.llvm.org/docs/Dialects/Vector/#vectorshuffle-vectorshuffleop), rather than an extract at -1.

## Related cases

[Issue #233054](https://github.com/llvm/llvm-project/issues/233054) also produces an invalid `vector.shuffle`, but there it is a shape-inconsistent result of folding `vector.extract_strided_slice` through `vector.insert_strided_slice`. Here the input `vector.shuffle` is valid, and `--convert-vector-to-llvm` creates an invalid `llvm.extractvalue` by treating the poison selector `-1` as an aggregate position. The mechanisms are distinct.

## LLM-Suggested Cause

The N-D `vector.shuffle` conversion uses each mask entry as an `llvm.extractvalue` position and does not implement the `-1` poison case handled by the one-dimensional path.

## LLM Declaration

LLM was used to prepare the bug report, and the bug itself was found and verified by a human.

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

Reply via email to