[all-commits] [llvm/llvm-project] 08eb5e: [MLIR] AllocaOp canonicalization for array allocat...

GabrielWu2004 via All-commits all-commits at lists.llvm.org
Mon Sep 7 22:21:36 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 08eb5edcafcc21faa841a75a29d0c2f2090535f3
      https://github.com/llvm/llvm-project/commit/08eb5edcafcc21faa841a75a29d0c2f2090535f3
  Author: GabrielWu2004 <101153587+GabrielWu2004 at users.noreply.github.com>
  Date:   2026-09-08 (Tue, 08 Sep 2026)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    M mlir/test/Dialect/LLVMIR/canonicalize.mlir

  Log Message:
  -----------
  [MLIR] AllocaOp canonicalization for array allocation in LLVM dialect (#221508)

Add the following canonicalization pattern to AllocaOp in MLIR's LLVM
dialect:

```
%n = constant(N)
%alloca = llvm.alloca %n x Ty
```
->
```
%one = constant(1)
%alloca = llvm.alloca %one x !llvm.array<N x Ty>
```

Here N is a constant representable with 64-bits. With this
canonicalization, the AllocaOp will be translated to `alloca [N x Ty]`
in LLVM IR. Without this canonicalization, the AllocaOp was translated
to `alloca Ty, N`. We prefer `alloca [N x Ty]` over `alloca Ty, N` for
fixed-size array allocation.

See [this
RFC](https://discourse.llvm.org/t/rfc-allocaop-canonicalization-in-mlirs-llvm-dialect/91734)
for more detailed problem motivation and description.

Assisted by: Codex



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list