-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement fcvt_to_uint_sat (f32x4 -> i32x4) for x86 #1822
Conversation
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 |
aa97b48
to
3fb3689
Compare
3fb3689
to
b55f84c
Compare
.as_any() | ||
.downcast_ref::<isa::x86::Isa>() | ||
.expect("the target ISA must be x86 at this point"); | ||
if x86_isa.isa_flags.use_avx512vl_simd() || x86_isa.isa_flags.use_avx512f_simd() { |
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.
Are the rounding semantics of the two alternative implementations equivalent? For the short case, vcvtps2udq
, the Intel manual says "When a conversion is inexact, the value returned is rounded according to the rounding control bits in the MXCSR register or the embedded rounding control bits." The slow path appears to use cvtt2si
(presumably, really, cvttps2pi
), and all the tt
variant conversion insns are round-towards-zero: "When a conversion is inexact, a truncated (round toward zero) result is returned."
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.
This is a good point: I had hoped MXCSR would have the right rounding mode but it does not. I added a run
filetest that passes with the long sequence and fails with the AVX512 sequence: it looks like the machines running the CI have AVX512 and therefore fail. I started playing around with a new recipe that embeds the rounding control (e.g. EvexContext::RoundingRegToRegFP { rc: EvexRoundingControl::RZ }
but this didn't immediately fix the test case (the emitted bytes aren't exactly right) so I will have to play around with this a bit more.
b55f84c
to
e10ff5e
Compare
This allows x86 machines with the right AVX features to lower fcvt_to_uint_sat.i32x4 to a single instruction.
This converts an `f32x4` into an `i32x4` (unsigned) with some rounding either by using an AVX512VL/F instruction--VCVTPS2UDQ--or a long sequence of SSE4.1 compatible instructions.
e10ff5e
to
229ed9d
Compare
Replacing this with #1990--I propose we look at the AVX512 lowering in a separate PR since it may get tricky (and this legalization is already tricky enough). |
This follows from #1821 and should be merged after that PR.[ready to review]Along the lines of #1820, this adds the necessary legalizations and instructions for enabling the Wasm SIMD spec tests with truncation instructions.