[Mlir-commits] [mlir] [mlir][vector] Add more tests for ConvertVectorToLLVM (5/n) (PR #104784)
Andrzej Warzyński
llvmlistbot at llvm.org
Tue Aug 20 06:06:57 PDT 2024
================
@@ -1155,266 +1154,276 @@ func.func @extract_index_element_from_vec_1d_scalable(%arg0: vector<[16]xindex>)
// -----
-func.func @extract_vec_2d_from_vec_3d(%arg0: vector<4x3x16xf32>) -> vector<3x16xf32> {
+func.func @extract_vec_2d_from_vec_3d_f32(%arg0: vector<4x3x16xf32>) -> vector<3x16xf32> {
%0 = vector.extract %arg0[0]: vector<3x16xf32> from vector<4x3x16xf32>
return %0 : vector<3x16xf32>
}
-// CHECK-LABEL: @extract_vec_2d_from_vec_3d
+// CHECK-LABEL: @extract_vec_2d_from_vec_3d_f32
// CHECK: llvm.extractvalue {{.*}}[0] : !llvm.array<4 x array<3 x vector<16xf32>>>
// CHECK: return {{.*}} : vector<3x16xf32>
-func.func @extract_vec_2d_from_vec_3d_scalable(%arg0: vector<4x3x[16]xf32>) -> vector<3x[16]xf32> {
+func.func @extract_vec_2d_from_vec_3d_f32_scalable(%arg0: vector<4x3x[16]xf32>) -> vector<3x[16]xf32> {
%0 = vector.extract %arg0[0]: vector<3x[16]xf32> from vector<4x3x[16]xf32>
return %0 : vector<3x[16]xf32>
}
-// CHECK-LABEL: @extract_vec_2d_from_vec_3d_scalable
+// CHECK-LABEL: @extract_vec_2d_from_vec_3d_f32_scalable
// CHECK: llvm.extractvalue {{.*}}[0] : !llvm.array<4 x array<3 x vector<[16]xf32>>>
// CHECK: return {{.*}} : vector<3x[16]xf32>
// -----
-func.func @extract_vec_1d_from_vec_3d(%arg0: vector<4x3x16xf32>) -> vector<16xf32> {
+func.func @extract_vec_1d_from_vec_3d_f32(%arg0: vector<4x3x16xf32>) -> vector<16xf32> {
%0 = vector.extract %arg0[0, 0]: vector<16xf32> from vector<4x3x16xf32>
return %0 : vector<16xf32>
}
-// CHECK-LABEL: @extract_vec_1d_from_vec_3d
+// CHECK-LABEL: @extract_vec_1d_from_vec_3d_f32
// CHECK: llvm.extractvalue {{.*}}[0, 0] : !llvm.array<4 x array<3 x vector<16xf32>>>
// CHECK: return {{.*}} : vector<16xf32>
-func.func @extract_vec_1d_from_vec_3d_scalable(%arg0: vector<4x3x[16]xf32>) -> vector<[16]xf32> {
+func.func @extract_vec_1d_from_vec_3d_f32_scalable(%arg0: vector<4x3x[16]xf32>) -> vector<[16]xf32> {
%0 = vector.extract %arg0[0, 0]: vector<[16]xf32> from vector<4x3x[16]xf32>
return %0 : vector<[16]xf32>
}
-// CHECK-LABEL: @extract_vec_1d_from_vec_3d_scalable
+// CHECK-LABEL: @extract_vec_1d_from_vec_3d_f32_scalable
// CHECK: llvm.extractvalue {{.*}}[0, 0] : !llvm.array<4 x array<3 x vector<[16]xf32>>>
// CHECK: return {{.*}} : vector<[16]xf32>
// -----
-func.func @extract_element_from_vec_3d(%arg0: vector<4x3x16xf32>) -> f32 {
+func.func @extract_scalar_from_vec_3d_f32(%arg0: vector<4x3x16xf32>) -> f32 {
%0 = vector.extract %arg0[0, 0, 0]: f32 from vector<4x3x16xf32>
return %0 : f32
}
-// CHECK-LABEL: @extract_element_from_vec_3d
+// CHECK-LABEL: @extract_scalar_from_vec_3d_f32
// CHECK: llvm.extractvalue {{.*}}[0, 0] : !llvm.array<4 x array<3 x vector<16xf32>>>
// CHECK: llvm.mlir.constant(0 : i64) : i64
// CHECK: llvm.extractelement {{.*}}[{{.*}} : i64] : vector<16xf32>
// CHECK: return {{.*}} : f32
-func.func @extract_element_from_vec_3d_scalable(%arg0: vector<4x3x[16]xf32>) -> f32 {
+func.func @extract_scalar_from_vec_3d_f32_scalable(%arg0: vector<4x3x[16]xf32>) -> f32 {
%0 = vector.extract %arg0[0, 0, 0]: f32 from vector<4x3x[16]xf32>
return %0 : f32
}
-// CHECK-LABEL: @extract_element_from_vec_3d_scalable
+// CHECK-LABEL: @extract_scalar_from_vec_3d_f32_scalable
// CHECK: llvm.extractvalue {{.*}}[0, 0] : !llvm.array<4 x array<3 x vector<[16]xf32>>>
// CHECK: llvm.mlir.constant(0 : i64) : i64
// CHECK: llvm.extractelement {{.*}}[{{.*}} : i64] : vector<[16]xf32>
// CHECK: return {{.*}} : f32
// -----
-func.func @extract_element_with_value_1d(%arg0: vector<16xf32>, %arg1: index) -> f32 {
+func.func @extract_scalar_from_vec_1d_f32_dynamic_idx(%arg0: vector<16xf32>, %arg1: index) -> f32 {
%0 = vector.extract %arg0[%arg1]: f32 from vector<16xf32>
return %0 : f32
}
-// CHECK-LABEL: @extract_element_with_value_1d
+// CHECK-LABEL: @extract_scalar_from_vec_1d_f32_dynamic_idx
// CHECK-SAME: %[[VEC:.+]]: vector<16xf32>, %[[INDEX:.+]]: index
// CHECK: %[[UC:.+]] = builtin.unrealized_conversion_cast %[[INDEX]] : index to i64
// CHECK: llvm.extractelement %[[VEC]][%[[UC]] : i64] : vector<16xf32>
-func.func @extract_element_with_value_1d_scalable(%arg0: vector<[16]xf32>, %arg1: index) -> f32 {
+func.func @extract_scalar_from_vec_1d_f32_dynamic_idx_scalable(%arg0: vector<[16]xf32>, %arg1: index) -> f32 {
%0 = vector.extract %arg0[%arg1]: f32 from vector<[16]xf32>
return %0 : f32
}
-// CHECK-LABEL: @extract_element_with_value_1d_scalable
+// CHECK-LABEL: @extract_scalar_from_vec_1d_f32_dynamic_idx_scalable
// CHECK-SAME: %[[VEC:.+]]: vector<[16]xf32>, %[[INDEX:.+]]: index
// CHECK: %[[UC:.+]] = builtin.unrealized_conversion_cast %[[INDEX]] : index to i64
// CHECK: llvm.extractelement %[[VEC]][%[[UC]] : i64] : vector<[16]xf32>
// -----
-func.func @extract_element_with_value_2d(%arg0: vector<1x16xf32>, %arg1: index) -> f32 {
+func.func @extract_scalar_from_vec_2d_f32_dynamic_idx(%arg0: vector<1x16xf32>, %arg1: index) -> f32 {
%0 = vector.extract %arg0[0, %arg1]: f32 from vector<1x16xf32>
return %0 : f32
}
// Multi-dim vectors are not supported but this test shouldn't crash.
-// CHECK-LABEL: @extract_element_with_value_2d(
+// CHECK-LABEL: @extract_scalar_from_vec_2d_f32_dynamic_idx(
+// CHECK: vector.extract
+
+func.func @extract_scalar_from_vec_2d_f32_dynamic_idx_scalable(%arg0: vector<1x[16]xf32>, %arg1: index) -> f32 {
+ %0 = vector.extract %arg0[0, %arg1]: f32 from vector<1x[16]xf32>
+ return %0 : f32
+}
----------------
banach-space wrote:
This is effectively a negative test. IMHO, checking "fixed-width" is sufficient in these cases (does switching to scalable vectors change anything here?). But also no harm in having more cases 😅
https://github.com/llvm/llvm-project/pull/104784
More information about the Mlir-commits
mailing list