[Mlir-commits] [mlir] [mlir][Vector] Add constant folding for vector.from_elements operation (PR #145849)
Diego Caballero
llvmlistbot at llvm.org
Thu Jun 26 10:25:01 PDT 2025
================
@@ -3075,6 +3075,20 @@ func.func @from_elements_to_elements_shuffle(%a: vector<4x2xf32>) -> vector<4x2x
// -----
+// CHECK-LABEL: func @from_elements_to_constant
+func.func @from_elements_to_constant() -> vector<2x2xi32> {
+ %c0_i32 = arith.constant 0 : i32
+ %c1_i32 = arith.constant 1 : i32
+ %c2_i32 = arith.constant 2 : i32
+ %c3_i32 = arith.constant 3 : i32
+ // CHECK: %[[RES:.*]] = arith.constant dense<{{\[\[0, 1\], \[2, 3\]\]}}> : vector<2x2xi32>
+ %res = vector.from_elements %c0_i32, %c1_i32, %c2_i32, %c3_i32 : vector<2x2xi32>
+ // CHECK: return %[[RES]]
+ return %res : vector<2x2xi32>
+}
+
+// -----
----------------
dcaballe wrote:
Could you add a negative test? For example, a case where not all the elements are constants?
https://github.com/llvm/llvm-project/pull/145849
More information about the Mlir-commits
mailing list