Skip to content

feat: add opt-in affine loop lowering - #1186

Merged
godofecht merged 12 commits into
mainfrom
codex/665-polyhedral
Oct 2, 2026
Merged

godofecht merged 12 commits into
mainfrom
codex/665-polyhedral

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Implements the first #665 slice in the native MLIR generator.

  • emits affine.for for static counted loops with positive constant steps
  • keeps scf.for as the default
  • rejects loop-carried values and control-flow exits from this path
  • adds an affine loop fixture and documents FLOWC_MLIR_AFFINE=1

Verified with the affine and default lowering checks, focused MLIR goldens, bootstrap fixed-point verification, and three-generation self-hosting.

Refs #665.

@godofecht

Copy link
Copy Markdown
Contributor Author

Extended affine eligibility to dynamic upper bounds with a positive constant step. The fixture now covers static and dynamic bounds. The affine path remains opt-in and the default scf.for path remains unchanged.

@godofecht

Copy link
Copy Markdown
Contributor Author

Added a native MLIR command golden for FLOWC_MLIR_AFFINE=1. It checks static and dynamic affine bounds, while the existing default path remains covered separately.

@godofecht

Copy link
Copy Markdown
Contributor Author

Extended the opt-in path to eligible parallel loops. They emit affine.parallel with constant positive steps when the body has no reductions, loop-carried values, or control-flow exits. The affine golden now covers affine.for and affine.parallel.

@godofecht

Copy link
Copy Markdown
Contributor Author

Added guarded affine tiling with FLOWC_MLIR_TILE=N. Static zero-based divisible loops emit nested affine.for loops with the original induction value reconstructed from tile and intra-tile indices. Partial tiles and carried/control-flow loops keep the existing lowering. Added a tile golden.

@godofecht

Copy link
Copy Markdown
Contributor Author

Extended tiling to dynamic and partial extents with affine.min for the final tile. The tiled golden now covers static, dynamic, and partial-loop cases.

@godofecht
godofecht force-pushed the codex/665-polyhedral branch from 98baf62 to 7aef92c Compare October 2, 2026 04:44
@godofecht
godofecht force-pushed the codex/665-polyhedral branch from 7aef92c to 6b46574 Compare October 2, 2026 05:04
@godofecht
godofecht merged commit b71e673 into main Oct 2, 2026
36 checks passed
@godofecht
godofecht deleted the codex/665-polyhedral branch October 12, 2026 23:02
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.

1 participant