ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 913 microarchs · 15,555 chips · 105 sources
Arch:
Tier:

SFPLZ

T1 tenstorrent simd insn
SFPLZ (Vectorized count leading zeroes)
SourceTenstorrent Official Tensix ISA Documentation (Wormhole & Blackhole) (tenstorrent_tt_isa)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeBlackholeA0 / WormholeB0
Tenstorrent Wormhole B0 & Blackhole A0
License & VersionApache-2.0
main
Upstreamhttps://github.com/tenstorrent/tt-isa-documentation
Privilegeuser
ExtensionsTensix, Vector Unit, BlackholeA0, WormholeB0

Summary

Performs lanewise count leading zeroes (lzcnt) on a vector of 32-bit unsigned integers or on the magnitudes of a vector of sign-magnitude integers. Inputs equal to zero are considered to have 32 leading zeroes. Lane flags can also be set based on whether the input was equal to zero.

Syntax / Encoding

TT_SFPLZ(0, /* u4 */ VC, /* u4 */ VD, /* u4 */ Mod1)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32Tensix-32b10000001xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x81000000

Operands

NameDescription
VC
VD
Mod1

Reference Notes

# `SFPLZ` (Vectorized count leading zeroes)

**Summary:** Performs lanewise count leading zeroes (`lzcnt`) on a vector of 32-bit unsigned integers or on the magnitudes of a vector of sign-magnitude integers. Inputs equal to zero are considered to have 32 leading zeroes. Lane flags can also be set based on whether the input was equal to zero.

**Backend execution unit:** [Vector Unit (SFPU)](VectorUnit.md), simple sub-unit

## Syntax

```c
TT_SFPLZ(0, /* u4 */ VC, /* u4 */ VD, /* u4 */ Mod1)
```

## Encoding

![](../../../Diagrams/Out/Bits32_SFPLZ.svg)

## Functional model

```c
if (Mod1 & 1) { // Reserved instruction modifier
  NonContractualBehavior {
    Mod1 &= ~1; // Current silicon behavior (not architecturally guaranteed)
  }
}
if (VD < 8 || VD == 16) {
  lanewise {
    if (LaneEnabled) {
      uint32_t c = LReg[VC].u32; // Unsigned integer or sign-magnitude integer.
      if (Mod1 & SFPLZ_MOD1_NOSGN_MASK) {
        // Mask off top bit (i.e. sign bit) of c.
        c &= 0x7fffffffu;
      }
      LReg[VD].u32 = (c != 0) ? __builtin_clz(c) : 32; // Any kind of integer.
      if (VD < 8) {
        if (Mod1 & SFPLZ_MOD1_CC_NE0) {
          LaneFlags = (c != 0);
        }
        if (Mod1 & SFPLZ_MOD1_CC_COMP) {
          LaneFlags = !LaneFlags;
        }
      }
    }
  }
}
```

Supporting definitions:
```c
#define SFPLZ_MOD1_CC_NE0     2
#define SFPLZ_MOD1_NOSGN_MASK 4
#define SFPLZ_MOD1_CC_COMP    8
```