Skip to content

Use Spans in cases where we can't infer them exactly - #9034

Merged
kripken merged 8 commits into
WebAssembly:mainfrom
kripken:span.proven
Aug 24, 2026
Merged

Use Spans in cases where we can't infer them exactly#9034
kripken merged 8 commits into
WebAssembly:mainfrom
kripken:span.proven

Conversation

@kripken

@kripken kripken commented Aug 21, 2026

Copy link
Copy Markdown
Member

x < 10 can be turned into Span{0,10} exactly, but we can actually infer
something from x < y even though y is unknown: x cannot be MAX_INT.
That is, we can prove the Span must be contained in Span{0, MAX_INT-1}
even if we can't provide an exact span.

To use this, move the getSpan() users out of the code that handles
constant constraints and into where non-constant ones are handled. Then
just use getProvenSpan instead of getSpan where possible.

This is important for certain loops (later PRs will depend on this).

@kripken
kripken requested a review from tlively August 21, 2026 22:56
@kripken
kripken requested a review from a team as a code owner August 21, 2026 22:56
Comment thread src/ir/constraint.cpp Outdated
if (!cc) {
// Not comparing to a constant, so we can't infer anything exact, but might
// if we just need something we can prove, and if we know the type.
if (!exact && type) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's invert this and turn it into an early return.

@kripken
kripken enabled auto-merge (squash) August 24, 2026 16:44
@kripken
kripken merged commit 3029fbb into WebAssembly:main Aug 24, 2026
16 checks passed
@kripken
kripken deleted the span.proven branch August 24, 2026 17:25
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