-
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
Legalize imul.i64x2 for both AVX and non-AVX x86 CPUs #1759
Conversation
e48a82c
to
fdcfd1c
Compare
Subscribe to Label Actioncc @bnjbvr
This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:x64", "cranelift:meta"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
85cd9eb
to
57cc3e2
Compare
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.
Looks pretty good! I wonder if the legalization couldn't be done in the meta-language directly using an ISA predicate (and thus avoiding the Any and downcasting).
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.
Unless guarding-legalizations-against-ISA-settings is easy to implement, the proposed approach here works fine. Thanks for the patch!
Without this special instruction, legalizing to the AVX512 instruction AND the SSE instruction sequence is impossible. This extra instruction would be rendered unnecessary by the x64 backend.
This is necessary when we would like to check specific ISA flags, e.g.
This instruction multiplies the lower 32 bits of two 64x2 unsigned integers into an i64x2; this is necessary for lowering Wasm's i64x2.mul.
This instruction does not exist in the SSE2 feature set; it can be added later with an VEX/EVEX encoding.
The `convert_i64x2_imul` custom legalization checks the ISA flags for AVX512DQ or AVX512VL support and legalizes `imul.i64x2` to an `x86_pmullq` in this case; if not, it uses a lengthy SSE2-compatible instruction sequence.
The
convert_i64x2_imul
custom legalization checks the ISA flags for AVX512DQ or AVX512VL support and legalizesimul.i64x2
to anx86_pmullq
in this case; if not, it uses a lengthy SSE2-compatible instruction sequence. For this logic to work, we need:x86_pmullq
(this additional instruction would go away in the new backend)TargetIsa
so that we can inspect its flags during legalizationx86_pmuludq
for implementing the SSE2-compatible instruction sequence