v_ffbl_b32 GPU Native ISA AMD Vector

Vector Arithmetic

v_ffbl_b32

Count the number of trailing "0" bits before the first "1" in a vector input and store the result into a vector register.

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

Encoding

Binary Layout (AMD CDNA 4)
0111111
31:25
VDST
24:17
00101110
16:9
SRC0
8:0
 

The ENC_VOP1 layout from AMD's machine-readable ISA specification (AMD CDNA 4). Opcode 46 in OP rebuilds 0x7E005C00, an identifier AMD lists for this encoding. Not the same in every generation: AMD RDNA 2 (opcode 58), AMD RDNA 1 (opcode 58). The same in AMD CDNA 3, AMD CDNA 2, AMD CDNA 1.

Format VOP1
Width 32 bits
Opcode 46
Identifier 0x7E005C00

Operands

  • VDST
    Written. N/A Data format: N/A (OPR_VGPR, FMT_NUM_I32)
  • SRC0
    Read. N/A Data format: N/A (OPR_SRC, FMT_NUM_U32)

In AMD's order, as its machine-readable ISA specification lists them for the ENC_VOP1 encoding (AMD CDNA 4).

GFX Target Compatibility

Per-target GFX compatibility has not yet been verified for this instruction.

Related

More in Vector Arithmetic

Reference

AMDGPU / GFX ISA

Description

Count the number of trailing "0" bits before the first "1" in a vector input and store the result into a vector register. Store -1 if there are no "1" bits in the input.

Semantics

D0.i32 = -1; // Set if no ones are found for i in 0 : 31 do // Search from LSB if S0.u32[i] == 1'1U then D0.i32 = i; break endif endfor

Example

V_FFBL_B32(0x00000000) => 0xffffffff
V_FFBL_B32(0xff000001) => 0
V_FFBL_B32(0xff000008) => 3
V_FFBL_B32(0xffff0000) => 16

Reproduced from AMD's official "AMD Instinct MI300" ISA Reference Guide for technical accuracy.

Sources