[Mlir-commits] [mlir] [MLIR][Canonicalization] Add shape_cast folding patterns (PR #183061)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Fri Feb 27 08:32:44 PST 2026
================
@@ -1078,6 +1078,19 @@ func.func @dont_fold_expand_collapse(%arg0: vector<1x1x64xf32>) -> vector<8x8xf3
// -----
+// CHECK-LABEL: func.func @fold_shape_cast_from_elements(
+// CHECK-SAME: %[[C1:.*]]: f32, %[[C2:.*]]: f32, %[[C3:.*]]: f32, %[[C4:.*]]: f32
+func.func @fold_shape_cast_from_elements(%c1: f32, %c2: f32, %c3: f32, %c4: f32) -> vector<2x2xf32>{
+// CHECK: %[[VAL_0:.*]] = vector.from_elements %[[C1]], %[[C2]], %[[C3]], %[[C4]] : vector<2x2xf32>
+// CHECK: return %[[VAL_0]] : vector<2x2xf32>
+// CHECK-NOT: vector.shape_cast
----------------
banach-space wrote:
```suggestion
// CHECK-LABEL: func.func @fold_shape_cast_from_elements(
// CHECK-SAME: %[[C1:.*]]: f32, %[[C2:.*]]: f32, %[[C3:.*]]: f32, %[[C4:.*]]: f32
// CHECK: %[[VAL_0:.*]] = vector.from_elements %[[C1]], %[[C2]], %[[C3]], %[[C4]] : vector<2x2xf32>
// CHECK: return %[[VAL_0]] : vector<2x2xf32>
// CHECK-NOT: vector.shape_cast
func.func @fold_shape_cast_from_elements(%c1: f32, %c2: f32, %c3: f32, %c4: f32) -> vector<2x2xf32>{
```
[nit] Other tests in this file seem to keep CHECK lines above the test function.
https://github.com/llvm/llvm-project/pull/183061
More information about the Mlir-commits
mailing list