Skip to content

[backend][cpu] hoist AMX stack buffers to the function entry block - #6

Merged
fschlimb merged 1 commit into
mainfrom
hoist-alloca
Nov 16, 2026
Merged

fschlimb merged 1 commit into
mainfrom
hoist-alloca

Conversation

@fschlimb

Copy link
Copy Markdown
Collaborator

Hoist allocas, restructure preparation pass.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

AMX buffer hoisting changes allocation lifetimes across regions, but missing upstream MLIR implementations and unavailable native/AMX validation require human review of the regression and runtime tests.

No open issues 🎉

What changed in this PR

This PR moves stack buffers created during CPU AMX lowering to the function entry block, avoiding dynamic LLVM stack allocations, and separates vector preparation from math approximation.

Changes:

  • Hoist operand-free AMX stack allocations to the entry block with at least 64-byte alignment.
  • Extract vector preparation into dedicated source and header files and update build integration.
  • Add a regression test checking allocation placement and alignment after a leading loop.
File Description
backends/​cpu/​test/​test_compiler_cpu.py Add regression coverage for entry-block allocations and alignment.
backends/​cpu/​PrepareCPUVectors.h Declare the extracted vector preparation pass factory.
backends/​cpu/​PrepareCPUVectors.cpp Implement vector preparation and AMX buffer hoisting.
backends/​cpu/​compiler.cmake Build the new source with matching RTTI settings.
backends/​cpu/​compiler_cpu.cpp Include the dedicated vector preparation header.
backends/​cpu/​ApproximateMath.h Remove the relocated vector preparation declaration.
backends/​cpu/​ApproximateMath.cpp Remove the relocated vector preparation implementation.

Review effort: Balanced

@fschlimb
fschlimb merged commit c7803b5 into main Nov 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants