Skip to content

Rewrite sliding window bounds let at the correct loop level#9150

Open
abadams wants to merge 2 commits into
mainfrom
abadams/sliding_window_bounds_rewrite_level
Open

Rewrite sliding window bounds let at the correct loop level#9150
abadams wants to merge 2 commits into
mainfrom
abadams/sliding_window_bounds_rewrite_level

Conversation

@abadams
Copy link
Copy Markdown
Member

@abadams abadams commented May 22, 2026

Sliding window populates a replacements map keyed by .min/.max let names and rewrites the first matching LetStmt encountered on the way out from the producer. That happens to hit the right let today because we don't inject bounds for that Func anywhere else that we might hit first (e.g. inside a loop on the consumer side, which is visited after the producer). That's a shaky assumption though. It caused a bug in another branch where I added more .min/.max declaration sites for other purposes. This PR explicitly only rewrites the ones at the Produce node's loop level. No test changes because there's no bug to trigger on main. This just makes the code more robust to future changes.

abadams and others added 2 commits May 22, 2026 12:41
Sliding window populates a replacements map keyed by .min/.max let names
and rewrites the first matching LetStmt encountered on the way out from
the producer. That happens to hit the right let today because bounds
inference places the lets driving production at the producer's loop
nest level, but other lets with the same names can appear at deeper
loop nest levels on the consume side. Gate replacement on
enclosing_loops.size() matching the depth recorded when the producer
was visited, so only lets at the producer's loop level are rewritten.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alexreinking
Copy link
Copy Markdown
Member

I'm not sure how the depth eliminates ambiguity. Does it merely make it less likely?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@3bb5d0c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/SlidingWindow.cpp 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9150   +/-   ##
=======================================
  Coverage        ?   69.23%           
=======================================
  Files           ?      254           
  Lines           ?    78220           
  Branches        ?    18714           
=======================================
  Hits            ?    54157           
  Misses          ?    18510           
  Partials        ?     5553           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abadams
Copy link
Copy Markdown
Member Author

abadams commented May 22, 2026

There should be a single set of .min/.max lets per loop. But I guess you're saying there could be sibling loops at the depth of the produce node, multiple of which contain .min/.max lets, but only one of which actually contains the produce node? Perhaps I should change it to check the loop name instead of the depth.

@alexreinking
Copy link
Copy Markdown
Member

alexreinking commented May 23, 2026

correctness_truncated_pyramid is a new failure. Not the CI changes from #9077

@alexreinking alexreinking mentioned this pull request May 23, 2026
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