VREM.VV

RISC-V VREM.VV Instruction Details

Instruction ManualR-type

Element-wise signed integer remainder.

Instruction Syntax

vrem.vv vd, vs2, vs1, vm
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
VVector IntegerDivide/Remainder

Instruction Behavior

VREM.VV computes signed remainders element-wise. A zero divisor does not trap; the remainder result is the dividend, and signed overflow of the corresponding divide gives remainder zero.

Quick Understanding & Search Notes

VREM.VV is an RVV integer remainder instruction paired with the VDIV/VDIVU divide rules.

A zero divisor does not raise an exception; the remainder result is the dividend.
Operands are interpreted as signed two's-complement integers.
The signed divide-overflow special case produces remainder zero.

Common Usage Scenarios

Modulo

Understand this scenario with real code like «vrem.vv v8, v12, v4, v0.t».

Cyclic Computation

Understand this scenario with real code like «vrem.vv v8, v12, v4, v0.t».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

A zero divisor returns the dividend as the remainder; the result is architecturally defined.
The signed overflow case, minimum integer divided by -1, returns remainder zero.
There is no scalar-divided-by-vector remainder form.

FAQ

Does VREM.VV trap on divide by zero?

No. RVV integer divide/remainder uses the scalar extreme-input results; remainder instructions return the dividend when the divisor is zero.