Skip to content

Fix bounds inference for implicit pure def with RVar args (#9102)#9103

Merged
abadams merged 2 commits intomainfrom
abadams/fix_9102
Apr 23, 2026
Merged

Fix bounds inference for implicit pure def with RVar args (#9102)#9103
abadams merged 2 commits intomainfrom
abadams/fix_9102

Conversation

@abadams
Copy link
Copy Markdown
Member

@abadams abadams commented Apr 22, 2026

When a Func's first definition is an update whose LHS uses an RVar directly (e.g. h(r.x) += ...), define_base_case synthesized an implicit pure definition but reused the RVar's name for the pure dimension. The resulting name collision caused bounds inference to resolve the update's RVar loop bounds to the pure dimension's output-buffer bounds instead of the RDom's, which broke scheduling directives like vectorize/unroll on the RVar.

Treat Variables with a defined reduction_domain the same way we treat Variables with a defined param: generate a fresh pure-arg Var instead of reusing the name.

Fixes #9102

This one was 100% Claude. I'm just opening the PR for it.

abadams and others added 2 commits April 22, 2026 10:15
When a Func's first definition is an update whose LHS uses an RVar
directly (e.g. `h(r.x) += ...`), define_base_case synthesized an
implicit pure definition but reused the RVar's name for the pure
dimension. The resulting name collision caused bounds inference to
resolve the update's RVar loop bounds to the pure dimension's
output-buffer bounds instead of the RDom's, which broke scheduling
directives like vectorize/unroll on the RVar.

Treat Variables with a defined reduction_domain the same way we treat
Variables with a defined param: generate a fresh pure-arg Var instead
of reusing the name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
LLVM's ARM64 backend fails to widen the 15-wide int32 vector store
produced by the original reproducer's vectorize(r.x) schedule. The
bug under test is about bounds inference, not vector widths, so round
the RDom extent up to 16 so vectorize lowers to clean NEON stores on
every supported target.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@alexreinking alexreinking left a comment

Choose a reason for hiding this comment

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

Easy fix and a regression test, woot!

@abadams abadams merged commit d5efca0 into main Apr 23, 2026
23 of 24 checks passed
@alexreinking alexreinking deleted the abadams/fix_9102 branch April 23, 2026 17:46
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.

Incorrect loop bounds when defining func using += with no Vars in sight

2 participants