diff options
author | Longsheng Mou <longshengmou@gmail.com> | 2024-09-11 17:10:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 17:10:58 +0800 |
commit | a4b0153c4f5f0d6bcf42fb2cb97dbdfad9c59e2c (patch) | |
tree | 02f4f5febba27ac06e06374458e8bffdb360bc51 /mlir/test/Conversion | |
parent | a8f3d303122d049e65b699870615d464b77b489f (diff) | |
download | llvm-a4b0153c4f5f0d6bcf42fb2cb97dbdfad9c59e2c.zip llvm-a4b0153c4f5f0d6bcf42fb2cb97dbdfad9c59e2c.tar.gz llvm-a4b0153c4f5f0d6bcf42fb2cb97dbdfad9c59e2c.tar.bz2 |
[mlir][vector] Support for extracting 1-element vectors in VectorExtractOpConversion (#107549)
This patch adds support for converting `vector.extract` that extract
1-element vectors into LLVM, fixing a crash in such cases.
E.g., `vector.extract %1[0]: vector<1xf32> from vector<2xf32>`. Fix
#61372.
Diffstat (limited to 'mlir/test/Conversion')
-rw-r--r-- | mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir b/mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir index bd14823..2fe9ba8 100644 --- a/mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir +++ b/mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir @@ -1130,6 +1130,30 @@ func.func @extract_scalar_from_vec_1d_f32_scalable(%arg0: vector<[16]xf32>) -> f // ----- +func.func @extract_vec_1e_from_vec_1d_f32(%arg0: vector<16xf32>) -> vector<1xf32> { + %0 = vector.extract %arg0[15]: vector<1xf32> from vector<16xf32> + return %0 : vector<1xf32> +} +// CHECK-LABEL: @extract_vec_1e_from_vec_1d_f32( +// CHECK-SAME: %[[A:.*]]: vector<16xf32>) +// CHECK: %[[T0:.*]] = llvm.mlir.constant(15 : i64) : i64 +// CHECK: %[[T1:.*]] = llvm.extractelement %[[A]][%[[T0]] : i64] : vector<16xf32> +// CHECK: %[[T2:.*]] = builtin.unrealized_conversion_cast %[[T1]] : f32 to vector<1xf32> +// CHECK: return %[[T2]] : vector<1xf32> + +func.func @extract_vec_1e_from_vec_1d_f32_scalable(%arg0: vector<[16]xf32>) -> vector<1xf32> { + %0 = vector.extract %arg0[15]: vector<1xf32> from vector<[16]xf32> + return %0 : vector<1xf32> +} +// CHECK-LABEL: @extract_vec_1e_from_vec_1d_f32_scalable( +// CHECK-SAME: %[[A:.*]]: vector<[16]xf32>) +// CHECK: %[[T0:.*]] = llvm.mlir.constant(15 : i64) : i64 +// CHECK: %[[T1:.*]] = llvm.extractelement %[[A]][%[[T0]] : i64] : vector<[16]xf32> +// CHECK: %[[T2:.*]] = builtin.unrealized_conversion_cast %[[T1]] : f32 to vector<1xf32> +// CHECK: return %[[T2]] : vector<1xf32> + +// ----- + func.func @extract_scalar_from_vec_1d_index(%arg0: vector<16xindex>) -> index { %0 = vector.extract %arg0[15]: index from vector<16xindex> return %0 : index |