[Mlir-commits] [mlir] [mlir][vector] Fix a crash in `VectorExtractOpConversion` (PR #115717)

Longsheng Mou llvmlistbot at llvm.org
Mon Nov 11 17:33:06 PST 2024


================
@@ -1105,9 +1105,8 @@ class VectorExtractOpConversion
 
     // One-shot extraction of vector from array (only requires extractvalue).
     // Except for extracting 1-element vectors.
-    if (isa<VectorType>(resultType) &&
-        position.size() !=
-            static_cast<size_t>(extractOp.getSourceVectorType().getRank())) {
----------------
CoTinker wrote:

Such `vector.insert` is illegal.
E.g.,
```
// mlir-opt insert.mlir
func.func @insert_scalar_into_vec_1d_f32(%arg0: f32, %arg1: vector<4x1xf32>) -> vector<4x1xf32> {
  %0 = vector.insert %arg0, %arg1[0] : f32 into vector<4x1xf32>
  return %0 : vector<4x1xf32>
}

insert.mlir:2:8: error: 'vector.insert' op expected position attribute rank to match the dest vector rank
  %0 = vector.insert %arg0, %arg1[0] : f32 into vector<4x1xf32>
       ^
insert.mlir:2:8: note: see current operation: %0 = "vector.insert"(%arg0, %arg1) <{static_position = array<i64: 0>}> : (f32, vector<4x1xf32>) -> vector<4x1xf32>
```

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


More information about the Mlir-commits mailing list