-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Legalize fmin/fmax with NaN quieting semantics #1821
Conversation
This instruction converts i32x4 to f32x4 in several AVX512 feature sets.
This instruction is necessary for lowering `fcvt_from_uint`.
This converts an `i32x4` into an `f32x4` with some rounding either by using an AVX512VL/F instruction--VCVTUDQ2PS--or a long sequence of SSE4.1 compatible instructions.
The NaN semantics of the Wasm SIMD spec do not closely align to x86's NaN semantics, resulting in generated code with extra instructions, e.g. to quiet NaNs. This flag allows users to assert that floating-point operations will not produce NaNs (for SIMD primarily, but this could be used eventually in a scalar context) so that Cranelift can emit fewer instructions--hopefully faster code.
This reuses the `x86_cvtt2si` instruction since the packed and scalar versions seem to group together well.
With user assertions, use CVTTPS2DQ directly; otherwise, use a lengthy sequence to quiet NaNs and saturate overflow.
Because the Wasm specification semantics for NaN handling in `min` and `max` are not x86-friendly, this legalization allows the user to generate code that is spec-compliant (a long sequence of instructions) or fast (a single instruction), using the `assert_no_nans` flag.
Subscribe to Label Actioncc @bnjbvr
This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:meta", "cranelift:wasm"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in the other issue for assert_in_bounds
; range analysis could get us the same result, although it's not implemented at all in Cranelift, afaik.
This builds on #1820 and should be merged after that PR.
The Wasm SIMD spec defines semantics for
fmin
andfmax
that require runtimes to produce long sequences of instructions. This change adds these long sequences through legalization but also provides an alternate mechansim, using theassert_no_nans
flag, for guaranteeing that special NaN handling is not required, thus resulting in a much shorter legalization.