alexcrichton opened PR #7136 from alexcrichton:rv64-divrem
to bytecodealliance:main
:
This commit's goal is to remove the usage of
gen_icmp
with division-related instructions in the riscv64 backend. I've opted for a slightly more verbose approach than what was present prior to make sign/zero extensions more precise and additionally enable some immediate-related optimizations.Divison/remainder by an immediate will no longer emit checks to see if a trap needs to be emitted. Instead only the raw
div
/rem
instructions are emitted. Additionally a few minor sign extensions are now avoided such as the dividend in 32-bit remainders/division because only the low 32-bits are inspected.Finally, while I was here, I went ahead an added
has_m
guards to all these lowering rules. The M extension is always required with riscv64 right now and won't work if it's turned off, but I figure it's not too bad to add in terms of completeness for now.As to the meat of the commit, the check for trapping value as part of division now happens without
gen_icmp
but insteadgen_trapif
which enables avoiding materializing the comparison's value into a register.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested afonso360 for a review on PR #7136.
alexcrichton requested cfallin for a review on PR #7136.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #7136.
alexcrichton requested elliottt for a review on PR #7136.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #7136.
alexcrichton updated PR #7136.
afonso360 submitted PR review:
Looks great! Thanks!
Also I'm gonna tag you for review on these riscv64 PRs @afonso360 but if it gets too much and/or you'd prefer I'd not, just let me know.
I'm happy to review these, but I'll let you know if I'm unable to for whatever reason.
afonso360 merged PR #7136.
Last updated: Nov 22 2024 at 17:03 UTC