RISC-V snez Pseudo-Instruction Details
Assembler pseudo-instructionSet if not equal zero pseudo-instruction, expands to sltu rd, x0, rs. Sets rd=1 if rs!=0, else rd=0. rd = (rs != 0) ? 1 : 0. Equivalent to unsigned comparison rs > 0.
What This Pseudo Instruction Is Saving You From Writing
Booleanize non-zero values. Exploits SLTU semantics: 0 < rs (unsigned) iff rs != 0. The result is consistent with C bool conversion (non-zero → true → 1).
Official Semantics Checklist
How To Read The Expansion
What You May See In objdump / Disassembly
Official References And Reading Order
This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.
When To Think Of It First
Pitfalls / Common Confusions
FAQ
Is snez a real RISC-V instruction?
snez is an assembler pseudo-instruction or alias, not a separate hardware opcode. The “Typical Real Expansion” section lists the official expansion, and behavior is defined by the expanded ISA instructions.
What is the main trap when using snez?
SNEZ is unsigned-based — but 0 < rs (unsigned) iff rs != 0, semantically correct in all cases