JIT: Fix small->uint->float casts with AVX-512 - #112892
Merged
Merged
Conversation
saucecontrol
marked this pull request as ready for review
February 25, 2025 04:34
This was referenced Feb 25, 2025
Open
jakobbotsch
reviewed
Feb 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #112871
In lowering, we had logic that inserted an intermediate cast to int when casting small types to/from floating. The float->small case was already handled by morph and will not appear in lowering. The other direction doesn't require a cast as long as the small type is handled correctly in the containment check and codegen.
The extra cast that was being inserted broke small->uint->floating conversions, for which uint->floating is now handled directly by AVX-512 instructions.
Diffs show a few hits where the uint->floating conversion instruction is restored, but all cases are on loads of unsigned small types where it wouldn't matter.
movzx rax, byte ptr [rbp-0x0F] vxorps xmm0, xmm0, xmm0 - vcvtsi2sd xmm0, xmm0, eax + vcvtusi2sd xmm0, xmm0, eaxI've added a regression test for the Fuzzlyn example, which does fail without the fix.
There are a few improvements as well. I removed a restriction on containment of memory operands for ulong->floating casts when we can use the AVX-512 conversion instructions:
And we're now skipping the insertion of unnecessary int casts, which eliminates some movs: