CZERO.NEZ

Conditional Zero Not Equal to Zero

CZERO.NEZ rd, rs1, rs2

Moves rs1 to rd if rs2 is zero, otherwise sets rd to zero.

Encoding

Binary Layout
0000111
31:25
rs2
24:20
rs1
19:15
111
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x0E007033
Extension Zicond

Operands

  • rd
    Destination register (integer)
  • rs1
    Source
  • rs2
    Condition

Example

CZERO.NEZ x10, x11, x12

// If x12 != 0, x10=0. Else x10=x11.

Related

Across architectures

Conditional Select (Branchless Move) : how x86, ARM, RISC-V, and PowerISA each do this.

More in Zicond

Description

CZERO.NEZ conditionally zeroes rd: it writes zero to rd if rs2 is non-zero, otherwise writes rs1 to rd. Useful for branch-free conditional selection.

Operation

if (R[rs2] != 0) R[rd] = 0; else R[rd] = R[rs1];