mulh
lyszt.net covers mulh and other RISC-V instructions in more detail.
Encoding format
Description
Multiplies the values of two registers as signed numbers and stores the high 32 bits of the product. In mulh rd, rs1, rs2, the upper half of the 64-bit product goes to rd. A nonzero result indicates that the full product does not fit in one register, and wide arithmetic and cryptography use both halves together with mul to recover it.
Official definition
MUL performs an XLEN-bit×XLEN-bit multiplication of rs1 by rs2 and places the lower XLEN bits in the destination register. MULH, MULHU, and MULHSU perform the same multiplication but return the upper XLEN bits of the full 2×XLEN-bit product, for signed×signed, unsigned×unsigned, and rs1×unsigned rs2 multiplication. If both the high and low bits of the same product are required, then the recommended code sequence is: MULH[[S]U] rdh, rs1, rs2; MUL rdl, rs1, rs2 (source register specifiers must be in same order and rdh cannot be the same as rs1 or rs2). Microarchitectures can then fuse these into a single multiply operation instead of performing two separate multiplies.