You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Zmmul is the integer multiplication subset of the RISC-V M extension. 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 m target 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. Zmmul fixes this problem by enabling only multiplication.
-Ctarget-feature=+zmmul can 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-elf embedded 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
rust-analyzer
Thanks to the recent addition of a target feature auto-sync, we don't need to worry about this
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 misa register for more details on this.
It is the responsibility of the user to guarantee that the instructions are implemented.
History
The target feature was implemented in RISC-V: Add Zmmul target feature #162552, where it was discussed that stabilization after a few weeks/months would be okay
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Oct 26, 2026
Seems like a no-brainer. Nominating for t-lang.
(We have been discussing in rust-lang/rust-forge#1122 what the stabilization process for target features should be, so far without clear conclusions.)
Hey RISC-V Group! This issue has been identified as a good "RISC-V candidate".
In case it's useful, here are some instructions for tackling these sorts of
issues. Maybe take a look?
Thanks! <3
@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.
traviscross
added
T-lang
Relevant to the language team
needs-fcp
This change is insta-stable, or significant enough to need a team FCP to proceed.
I-lang-radar
Items that are on lang's radar and will need eventual work or consideration.
P-lang-drag-1
Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang
labels
Oct 28, 2026
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I-lang-nominatedNominated for discussion during a lang team meeting.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.O-riscvTarget: RISC-V architectureP-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-langS-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ↩