[Mlir-commits] [mlir] [MLIR] AllocaOp canonicalization for array allocation in LLVM dialect (PR #221508)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 7 09:48:06 PDT 2026


================
@@ -469,6 +469,25 @@ LogicalResult AllocaOp::verify() {
   return success();
 }
 
+LogicalResult AllocaOp::canonicalize(AllocaOp op, PatternRewriter &rewriter) {
+  // Convert `alloca Ty, C` to the canonical `alloca [C x Ty], 1` form.
+  APInt numElements;
+  if (!matchPattern(op.getArraySize(), m_ConstantInt(&numElements)) ||
+      numElements.isOne() || numElements.getActiveBits() > 64)
+    return failure();
+
+  Type arrayType =
----------------
GabrielWu2004 wrote:

Fixed

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


More information about the Mlir-commits mailing list