Repository navigation
RISC-V: stabilize Zmmul target feature - #164992
TechnoPorg wants to merge 1 commit into
Conversation
|
Target features are being changed; ensure all ABI effects are being accounted for cc @RalfJung Some changes occurred in cc @Amanieu, @folkertdev, @sayantn |
|
|
It already does imply Zmmul. |
|
Seems like a no-brainer. Nominating for t-lang. |
|
Hey RISC-V Group! This issue has been identified as a good "RISC-V candidate". |
|
@davidtwco / @BoxyUwU do you want t-compiler to be included in this FCP? We have been inconsistent about this in the past; sometimes t-compiler was included but often it was not. |
|
Hello @davidtwco and @BoxyUwU! Gentle ping about this :) |
|
I think T-compiler should be on target modifier stabilisations, just as a sanity check for any ABI issues or anything else we might be aware of |
|
@davidtwco this target feature isn't a target modifier (as it's sound to link things with it enabled and disabled together). Should T-compiler be included in the FCP of target features that aren't target modifiers? |
|
Yeah I think the general conclusion was that t-lang and t-compiler should both be included to make sure nothing is missed regarding ABI interactions or similar. EDIT: oh wait that was the message David wrote just above. I didn't realize he wrote "target modifier". Likely a typo? |
|
@rfcbot merge |
|
@rfcbot fcp merge compiler,lang |
|
@beetrees has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
Stabilization report
Summary
Zmmul is the integer multiplication subset of the RISC-V
Mextension. It enables LLVM to lower multiplications to the "MUL, MULH, MULHU, MULHSU, and (for RV64 only) MULW"1 instructions, while keeping divisions implemented in software.This is useful for constrained embedded applications where multiplication operations are important enough for performance to warrant a hardware implementation, but division is rarely ever performed and so the extra cost of a hardware divider cannot be justified.
Using the
mtarget feature could result in undefined behaviour by lowering to unimplemented division instructions, but excluding it leads to noticeably worse performance because hardware multiplication can't be used.Zmmulfixes this problem by enabling only multiplication.Tracking issue:
Reference PRs:
zmmultarget feature reference#2396 (stabilize Zmmul)What is stabilized
-Ctarget-feature=+zmmulcan now be passed without a warning.#[cfg(target_feature = "zmmul")]and#[target_feature(enable = "zmmul")]are accepted.Feedback
Nightly use
This has been in use at $INTERNSHIP for our
riscv32i-unknown-none-elfembedded project for a few months now and works as expected: LLVM lowers to multiplication instructions but not division instructions.Coverage
There is currently no test coverage in rust-lang/rust. Given that this is just forwarded to LLVM, I think it's fair to put the test burden on LLVM and not rustc.
Tool changes
Type system, opsem
Sound by default?
Code with this target feature enabled is sound unless it is executed in an environment where integer multiplication instructions are not available. See some of the discussion in #162552 about whether M implies Zmmul and the guidelines around the
misaregister for more details on this.It is the responsibility of the user to guarantee that the instructions are implemented.
History
r? beetrees
cc @RalfJung, @kraj, @sweiglbosker as participants on the previous thread
@rustbot label O-riscv
Footnotes
Spec: https://github.com/riscv/riscv-isa-manual/blob/20250508/src/m-st-ext.adoc#zmmul-extension-version-10 ↩