Skip to content

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

Open
kripken wants to merge 6 commits into
WebAssembly:mainfrom
kripken:span.proven
Open

Use Spans in cases where we can't infer them exactly#9034
kripken wants to merge 6 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
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.

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