[Mlir-commits] [mlir] [MLIR][SROA] Replace pattern based approach with a one-shot one (PR #85437)

Mehdi Amini llvmlistbot at llvm.org
Sat Mar 16 12:54:23 PDT 2024


================
@@ -289,14 +293,18 @@ llvm.func @memcpy_src(%other_array: !llvm.ptr) -> i32 {
 
 // CHECK-LABEL: llvm.func @memcpy_double
 llvm.func @memcpy_double() -> i32 {
-  // CHECK-DAG: %[[ALLOCA_LEN:.*]] = llvm.mlir.constant(1 : i32) : i32
-  // CHECK-DAG: %[[MEMCPY_LEN:.*]] = llvm.mlir.constant(4 : i32) : i32
+  // CHECK: %[[ALLOCA_LEN:.*]] = llvm.mlir.constant(1 : i32) : i32
   %0 = llvm.mlir.constant(1 : i32) : i32
-  // CHECK-COUNT-2: = llvm.alloca %[[ALLOCA_LEN]] x i32
+  // CHECK: = llvm.alloca %[[ALLOCA_LEN]] x i32
+  // TODO: This should also disappear.
+  // CHECK: = llvm.alloca %[[ALLOCA_LEN]] x !llvm.array<1 x i32>
----------------
joker-eph wrote:

> The rewriter was able to fold the GEPOp zero indexing GEPOp away, while this is not done be the builder.

It's not the builder/rewriter I believe, instead it is the Greedy driver doing a lot of cleanup like this on the fly.

That said you could do it yourself by using `createOrFold` instead of `create` if these are GEPOp you are creating. And otherwise have the algorithm match GEPOp and fold them as it goes.

https://github.com/llvm/llvm-project/pull/85437


More information about the Mlir-commits mailing list