[Mlir-commits] [mlir] [mlir][VectorToSPIRV] Add conversion for vector.extract with dynamic indices (PR #114137)
Jakub Kuderski
llvmlistbot at llvm.org
Wed Oct 30 16:13:38 PDT 2024
================
@@ -216,6 +236,28 @@ func.func @insert_size1_vector(%arg0 : vector<1xf32>, %arg1: f32) -> vector<1xf3
// -----
+// CHECK-LABEL: @insert_dynamic
+// CHECK-SAME: %[[VAL:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[ARG2:.*]]: index
+// CHECK: %[[ID:.+]] = builtin.unrealized_conversion_cast %[[ARG2]] : index to i32
+// CHECK: spirv.VectorInsertDynamic %[[VAL]], %[[V]][%[[ID]]] : vector<4xf32>, i32
+func.func @insert_dynamic(%val: f32, %arg0 : vector<4xf32>, %id : index) -> vector<4xf32> {
+ %0 = vector.insert %val, %arg0[%id] : f32 into vector<4xf32>
+ return %0: vector<4xf32>
+}
+
+// -----
+
+// CHECK-LABEL: @insert_dynamic_cst
+// CHECK-SAME: %[[VAL:.*]]: f32, %[[V:.*]]: vector<4xf32>
+// CHECK: spirv.CompositeInsert %[[VAL]], %[[V]][2 : i32] : f32 into vector<4xf32>
+func.func @insert_dynamic_cst(%val: f32, %arg0 : vector<4xf32>) -> vector<4xf32> {
+ %idx = arith.constant 2 : index
+ %0 = vector.insert %val, %arg0[%idx] : f32 into vector<4xf32>
----------------
kuhar wrote:
By 'the scalar case' I mean `vector<1xT>` which becomes `T` in SPIR-V
https://github.com/llvm/llvm-project/pull/114137
More information about the Mlir-commits
mailing list