bgtu

RISC-V bgtu Pseudo-Instruction Details

Assembler pseudo-instruction

Unsigned greater-than branch pseudo-instruction. It swaps the two source registers and uses BLTU: bgtu rs1, rs2, offset is equivalent to bltu rs2, rs1, offset.

What You Write
bgtu rs1, rs2, offset
Typical Real Expansion
bltu rs2, rs1, offset

What This Pseudo Instruction Is Saving You From Writing

Base RISC-V branches provide a compact set such as equal/not-equal and less-than/greater-or-equal; this pseudo-instruction swaps operands or compares with x0 so source code matches the programmer condition.

bgtu primarily means "Unsigned greater-than branch". 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 bgtu as an assembler-level pseudo-instruction or alias; hardware executes the expanded real instruction sequence.
The real semantics come from the ISA definitions of BLTU and the other expanded instructions, not from a separate bgtu hardware opcode.
Signed or unsigned comparison behavior is inherited from BEQ/BNE/BLT/BGE/BLTU/BGEU; zero-test aliases simply use x0 as one operand.

How To Read The Expansion

Step 1
Assembler expands to bltu rs2, rs1, offset

What You May See In objdump / Disassembly

Disassemblers may show the pseudo name or the expanded real branch; when reading semantics, check whether rs1/rs2 were swapped.

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

Address comparison
Array bounds check (unsigned)
Memory size comparison

Pitfalls / Common Confusions

This is an unsigned comparison; negative two’s-complement values are treated as large unsigned numbers
Branch target range comes from the real B-type branch immediate, about ±4 KiB
Some forms are implemented by swapping operands; do not reverse the operands incorrectly when expanding by hand

FAQ

Is bgtu a real RISC-V instruction?

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

This is an unsigned comparison; negative two’s-complement values are treated as large unsigned numbers