s_sub_u32 GPU Native ISA AMD Scalar

Scalar Arithmetic

s_sub_u32 SDST, S0, S1

Subtract two 32-bit unsigned scalar operands, wavefront-uniform.

Also written as s_sub_co_u32. AMD's machine-readable ISA specification lists this name for the same instruction.

Encoding

Binary Layout (AMD CDNA 4)
10
31:30
0000001
29:23
SDST
22:16
SSRC1
15:8
SSRC0
7:0
 

The ENC_SOP2 layout from AMD's machine-readable ISA specification (AMD CDNA 4). Opcode 1 in OP rebuilds 0x80800000, an identifier AMD lists for this encoding. The same in the other 7 generations that define it.

Format SOP2
Width 32 bits
Opcode 1
Identifier 0x80800000
Execution Unit Scalar ALU
Register Classes SGPR

Operands

  • SDST
    Destination SGPR
  • S0
    Minuend SGPR/constant
  • S1
    Subtrahend SGPR/constant

GFX Target Compatibility

TargetSupport
gfx942✅ Supported
gfx1100✅ Supported

Related PTX Concepts

Integer Subtraction ↗
equivalent with restrictions
sub (PTX)
Subtract with Borrow-Out ↗
equivalent with restrictions
sub.cc (PTX)

Related

More in Scalar Arithmetic

Reference

AMDGPU / GFX ISA

Description

Subtract the second unsigned 32-bit integer input from the first input, store the result into a scalar register and store the carry-out bit into SCC.

Semantics

SDST = S0.u32 - S1.u32; SCC = borrow-out.

Example

s_sub_u32  s2, s0, s1   // s2 = s0 - s1

Original illustrative example, written for this site (not reproduced from a specific AMD document).

Sources