Legalize fmin/fmax with NaN quieting semantics#1821
Closed
abrown wants to merge 12 commits intobytecodealliance:masterfrom
Closed
Legalize fmin/fmax with NaN quieting semantics#1821abrown wants to merge 12 commits intobytecodealliance:masterfrom
abrown wants to merge 12 commits intobytecodealliance:masterfrom
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 DetailsThis 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 |
bnjbvr
reviewed
Jun 9, 2020
Member
bnjbvr
left a comment
There was a problem hiding this comment.
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 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This builds on #1820 and should be merged after that PR.
The Wasm SIMD spec defines semantics for
fminandfmaxthat 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_nansflag, for guaranteeing that special NaN handling is not required, thus resulting in a much shorter legalization.