seqz

RISC-V seqz Pseudo-Instruction Details

Assembler pseudo-instruction

Set if equal zero pseudo-instruction, expands to sltiu rd, rs, 1. Sets rd=1 if rs==0, else rd=0. rd = (rs == 0) ? 1 : 0. Common for null pointer checks and booleanization.

What You Write
seqz rd, rs
Typical Real Expansion
sltiu rd, rs, 1

What This Pseudo Instruction Is Saving You From Writing

Directly expresses 'equal to zero' comparison — exploits SLTIU semantics: rs < 1 iff rs == 0. Effectively booleanizes a pointer or value.

seqz primarily means "Set 1 if equal to zero". It is assembler-level shorthand; when debugging, auditing, or reading machine code, reason from the real expansion and relocation semantics listed on this page.

Official Semantics Checklist

The official assembly manual treats seqz as an assembler-level pseudo-instruction or alias; hardware executes the expanded real instruction sequence.
The real semantics come from the ISA definitions of SLTIU and the other expanded instructions, not from a separate seqz hardware opcode.

How To Read The Expansion

Step 1
Assembler expands to sltiu rd, rs, 1.
Step 2
SLTIU performs unsigned comparison: if rs < 1 (i.e., rs == 0), rd = 1; else rd = 0.

What You May See In objdump / Disassembly

sltiu rd, rs, 1 shown as seqz rd, rs in disassembly. Note: rd=1 when rs==0, rd=0 when rs!=0.

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

Check if pointer is NULL
Booleanize any value (C's bool conversion, inverted logic)
Comparison part of conditional assignment (ternary operator)
Detect if a computation result is zero

Pitfalls / Common Confusions

seqz means '1 if zero' — inverted from C bool conversion (0→false, non-zero→true); use not or xori to invert
SLTIU is unsigned comparison — but seqz only checks 'less than 1', so negative values (as large unsigned) return 0, which is semantically correct
When testing pointers for null, ensure they are not corrupted by sign extension (mind upper 32 bits on RV64)

FAQ

Is seqz a real RISC-V instruction?

seqz 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 seqz?

seqz means '1 if zero' — inverted from C bool conversion (0→false, non-zero→true); use not or xori to invert