Skip to content

Cranelift: apply NaN canonicalization to libcalls#12963

Open
tschneidereit wants to merge 1 commit intobytecodealliance:mainfrom
tschneidereit:nan-canon-libcalls
Open

Cranelift: apply NaN canonicalization to libcalls#12963
tschneidereit wants to merge 1 commit intobytecodealliance:mainfrom
tschneidereit:nan-canon-libcalls

Conversation

@tschneidereit
Copy link
Copy Markdown
Member

This probably doesn't matter much in the real world, since the libcalls are only emitted on pre-SSE4.1 x64, and hence on CPUs released before 2007 (Intel) and 2011 (AMD). It does trip up the cranelift-fuzzgen fuzzer though, since the libcalls are interpreted differently between Pulley and Cranelift. In a local (Aarch64, which I think matters) run of maybe an hour, I got 30 artifacts based on this, inhibiting other explorations.

Alternatively, we could make SSE4.1 a requirement and remove the libcalls entirely: they're unused on all other platforms.

@tschneidereit tschneidereit requested a review from a team as a code owner April 4, 2026 18:27
@tschneidereit tschneidereit requested review from fitzgen and removed request for a team April 4, 2026 18:27
This probably doesn't matter much in the real world, since the libcalls are only emitted on pre-SSE4.1 x64, and hence on CPUs released before 2007 (Intel) and 2011 (AMD). It does trip up the fuzzer though, since the libcalls are interpreted differently between Pulley and Cranelift.

Alternatively, we could make SSE4.1 a requirement and remove the libcalls entirely: they're unused on all other platforms.
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Apr 4, 2026
Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks! Would it be possible to add some tests for this as well?

Additionally, I think it's ok to exempt CallIndirect and instead match on the call target of Call to ensure that this is only applied to libcalls as opposed to all functions in general.

@cfallin
Copy link
Copy Markdown
Member

cfallin commented Apr 6, 2026

Alternatively, we could make SSE4.1 a requirement and remove the libcalls entirely: they're unused on all other platforms.

This has definitely crossed my mind at several points in the past too (it's very annoying to have to polyfill things) but FWIW, we made a somewhat explicit decision a few years ago to try to support everything on x86-64 all the way back to the first x86-64 (so, just SSE2) -- and actually Alex did most of the SIMD work for that -- so we would have the strongest possible "we support x86" story :-) At some point it may become so unimportant that we can drop it but for now at least it feels nice to keep if we can (so, thanks for the work to include libcalls here!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants