Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv64: Implement a few SIMD arithmetic ops #6268

Merged
merged 8 commits into from
Apr 25, 2023

Conversation

afonso360
Copy link
Contributor

馃憢 Hey,

This PR Implements a few more arithmetic ops, I didn't want to implement too many since I want to get the wasmtime testsuite working to get better test coverage.

Similarly to #6266, I've also switched the scalar rules to match only scalars, since most of them used fits_in_64 which also matches vectors.

I also had accidentally switched the order of the registers in VecAluRRR, which I only noticed when implementing isub.

Implemented ops are:

  • isub
  • imul
  • smulhi
  • umulhi
  • band
  • bor
  • bxor

This PR is based on #6266, I'll rebase when that lands.

@afonso360 afonso360 requested a review from a team as a code owner April 23, 2023 11:33
@afonso360 afonso360 requested review from jameysharp and removed request for a team April 23, 2023 11:33
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:meta Everything related to the meta-language. labels Apr 23, 2023
Comment on lines 250 to 257
VecAluOpRRR::Vadd => write!(f, "vadd.vv"),
VecAluOpRRR::Vsub => write!(f, "vsub.vv"),
VecAluOpRRR::Vmul => write!(f, "vmul.vv"),
VecAluOpRRR::Vmulh => write!(f, "vmulh.vv"),
VecAluOpRRR::Vmulhu => write!(f, "vmulhu.vv"),
VecAluOpRRR::Vand => write!(f, "vand.vv"),
VecAluOpRRR::Vor => write!(f, "vor.vv"),
VecAluOpRRR::Vxor => write!(f, "vxor.vv"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these all follow the same pattern, one thing I found helpful for AVX was do do something like:

let mut s = format!("{self:?}");
s.make_ascii_lowercase();
s.push_str(".vv");
f.write_str(&s)

which can cut down on codegen times and additionally make this a bit easier to maintain. If the instructions have all sorts of different names though this may not work out well

Copy link
Contributor Author

@afonso360 afonso360 Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have another variant for all of these, which is v*.vx. However, it should still be fairly easy to fit into that scheme when we do need it.

Edit: Hmm, It might not be so easy, because I was planning on renaming these enum arms into VaddVV and VaddVX which would then break that. But I don't mind doing it this way for now and figuring it out later.

target aarch64
target s390x
set enable_simd
target x86_64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind copying over the target x86_64 has_sse41=false line as well from the original test? (maybe lost through a rebase by accident)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes me idly think that perhaps there should be a ; skip: riscv directive for filetests or similar, but not something to be added in this PR of course.

@afonso360 afonso360 added this pull request to the merge queue Apr 25, 2023
Merged via the queue into bytecodealliance:main with commit 62cbb50 Apr 25, 2023
@afonso360 afonso360 deleted the riscv-vec-arithmetic branch April 25, 2023 17:16
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Apr 28, 2023
* riscv64: Swap order of `VecAluRRR` source registers

These were accidentally reversed from what we declare in the isle emit helper

* riscv64: Add SIMD `isub`

* riscv64: Add SIMD `imul`

* riscv64: Add `{u,s}mulhi`

* riscv64: Add `b{and,or,xor}`

* cranelift: Move `imul.i8x16` runtest to separate file

Looks like x86 does not implement it

* riscv64: Better formatting for `VecAluOpRRR`

* cranelift: Enable x86 SIMD tests with `has_sse41=false`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants