Skip to content

feat: add loop invariant code motion pass#38

Merged
arnoox merged 6 commits intomainfrom
pr-f4/licm
Mar 29, 2026
Merged

feat: add loop invariant code motion pass#38
arnoox merged 6 commits intomainfrom
pr-f4/licm

Conversation

@arnoox
Copy link
Copy Markdown
Owner

@arnoox arnoox commented Mar 27, 2026

Summary

  • Adds licm as the final post-lowering optimizer pass
  • Detects natural loops via back-edges and dominator-tree analysis
  • Hoists side-effect-free loop-invariant instructions into loop preheader blocks
  • Runs last — after GVN and branch_fold — so loop exit conditions are already simplified and redundancies removed before hoisting decisions are made

Pipeline position

... → gvn → dead_instrs → branch_fold → dead_instrs → licm

Test plan

  • cargo test -p herkos-core --lib — 232 tests pass (18 new licm tests)
  • cargo clippy — clean
  • cargo fmt --check

Stack

This is PR F4 of 4 (last) in the optimizer split. Stacked on PR F3 (pr-f3/gvn#37).

PR Pass Status
F1 branch_fold #35
F2 local_cse #36
F3 gvn #37
F4 (this) licm

🤖 Generated with Claude Code

bench and others added 4 commits March 27, 2026 08:18
Adds `licm` as the final post-lowering optimizer pass. Detects natural
loops via back-edges and dominator-tree analysis, then hoists
side-effect-free loop-invariant instructions into loop preheader blocks.
Runs after GVN and branch_fold so redundancies are resolved before
hoisting decisions are made.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@arnoox arnoox changed the base branch from pr-f3/gvn to main March 28, 2026 16:28
@arnoox arnoox merged commit 1c44219 into main Mar 29, 2026
1 check 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.

1 participant