sltz

RISC-V sltz Pseudo-Instruction Details

Assembler pseudo-instruction

Set-if-less-than-zero pseudo-instruction, expanding to slt rd, rs, x0. If rs is less than 0 as a signed value, rd=1; otherwise rd=0.

What You Write
sltz rd, rs
Typical Real Expansion
slt rd, rs, x0

What This Pseudo Instruction Is Saving You From Writing

Writes a common sign test as a readable pseudo-instruction, using SLT with x0 to produce a 0/1 Boolean result.

sltz primarily means "Signed set if less than 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 sltz as an assembler-level pseudo-instruction or alias; hardware executes the expanded real instruction sequence.
The real semantics come from the ISA definitions of SLT and the other expanded instructions, not from a separate sltz hardware opcode.

How To Read The Expansion

Step 1
Assembler expands to slt rd, rs, x0

What You May See In objdump / Disassembly

Disassembly may show the pseudo name or the real SLT-with-x0 expansion.

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

Convert a signed comparison into 0/1
Booleanize a condition before an if-style use
Check sign meaning rather than unsigned magnitude

Pitfalls / Common Confusions

Uses signed SLT; use SLTU-related forms for unsigned tests
The result is only 0 or 1, not an all-bits mask
When rs=x0 the result is always 0

FAQ

Is sltz a real RISC-V instruction?

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

Uses signed SLT; use SLTU-related forms for unsigned tests