Skip to content

perf(optimizer): hoist stable buffer property loops - #2066

Merged
nahime0 merged 15 commits into
mainfrom
perf/hoist-buffer-property-loops
Oct 25, 2026
Merged

nahime0 merged 15 commits into
mainfrom
perf/hoist-buffer-property-loops

Conversation

@nahime0

@nahime0 nahime0 commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Loops over a stable buffer property on $this currently repeat the property read and handle resolution at every element access. Move a guaranteed property read into a preheader and reuse the existing descriptor hoist. Body-only reads get a scalar entry guard, preserving zero-trip uninitialized-property behavior and the first entered error.

Calls, stores, frees, conditional reads, faulting prefixes and live-out header SSA values retain their existing form. Property instruction IDs and lexical metadata stay intact. Raw packed-record addresses are shared before descriptor conversion, preserving reuse of an address checked before the loop. Adds CFG and exception regressions, optimizer-on/off fixtures, five-target emission coverage, an example and updated compiler documentation. Tracks CJ task ad0374ba.

Depends on #2044. This branch starts at its exact head d256479dfdb749b06b41774d437bfb3658583ca3; review this follow-up delta separately. Do not enqueue before #2044 has merged.

Validation: git diff --check passes. Local builds and tests were explicitly disabled by the user; CI supplies compilation/runtime coverage. Claude static review is clean on 31e1fd557564b7c48f1ac74b8ae5c51bdea1d88a (delegation fc911e56-3316-4db4-9f48-e173b0a7c364).

@github-actions github-actions Bot added area:eir Touches EIR definitions, lowering, validation, or passes. area:optimizer Touches AST or EIR optimization passes. size:l Large pull request. type:triage Needs a conventional title or branch prefix before review. labels Oct 24, 2026
@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge after the stated dependency, #2044, lands.

Summary

The latest changes fix the order of buffer optimizations.

  • Stable buffer properties now share reads and handle work.
  • Loop buffer resolution runs before hoisted values are loaded.

The previous finding is addressed. No new actionable issues were found. Static checks only; builds and runtime tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Hoist stable property reads"] --> B["Share raw record addresses"]
  B --> C["Hoist loop descriptors"]
  C --> D["Share remaining descriptors"]
Loading

Reviews (2) · Last reviewed commit: "docs(optimizer): describe property reuse..." · Reviewed by Greptile

Comment thread src/ir_passes/buffer_access.rs
@nahime0
nahime0 added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to invalid changes in the merge commit Oct 25, 2026
@nahime0
nahime0 added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit e5ce918 Oct 25, 2026
147 of 148 checks passed
@nahime0
nahime0 deleted the perf/hoist-buffer-property-loops branch October 25, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:eir Touches EIR definitions, lowering, validation, or passes. area:optimizer Touches AST or EIR optimization passes. size:l Large pull request. type:triage Needs a conventional title or branch prefix before review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant