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

SFPLE

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

Summary

Operating lanewise on 32-bit sign-magnitude integers, performs a comparison VD <= VC, and writes the result of the comparison to VD and/or LaneFlags and/or the top of the vector conditional execution stack. Can instead be operating on FP32 values, in which case it uses the total order where -NaN < -Inf < ... < -0 < +0 < ... < +Inf < +NaN.

Syntax / Encoding

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

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32Tensix-32b10010110xxxxxxxxxxxxxxxxxxxxxxxx0xff000000 / 0x96000000

Operands

NameDescription
VC
VD
Mod1

Reference Notes

# `SFPLE` (Vectorized sign-magnitude integer comparison)

**Summary:** Operating lanewise on 32-bit sign-magnitude integers, performs a comparison `VD <= VC`, and writes the result of the comparison to `VD` and/or `LaneFlags` and/or the top of the vector conditional execution stack. Can instead be operating on FP32 values, in which case it uses the total order where -NaN < -Inf < ... < -0 < +0 < ... < +Inf < +NaN.

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

> [!TIP]
> This instruction is new in Blackhole, as is its inverse, [`SFPGT`](SFPGT.md).

## Syntax

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

## Encoding

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

## Functional model

```c
unsigned VB = VD;
lanewise {
  if (VD < 12 || LaneConfig.DISABLE_BACKDOOR_LOAD) {
    bool IsVcGreaterEqual = !SignMagIsSmaller(LReg[VC].u32, LReg[VB].u32);
    if (LaneEnabled) {
      if (Mod1 & SFPLE_MOD1_SET_VD) {
        if (VD < 8 || VD == 16) LReg[VD].i32 = IsVcGreaterEqual ? -1 : 0;
      }
      if (Mod1 & SFPLE_MOD1_SET_CC) {
        LaneFlags = IsVcGreaterEqual;
      }
    }
    if (Mod1 & SFPLE_MOD1_MUTATE_STACK) {
      // On an empty stack, this writes Entries[7] (as ReplaceTop does), which only a stack moved past its ends reads.
      FlagStackEntry Top = FlagStack.Top();
      if (Mod1 & SFPLE_MOD1_MUTATE_OR) {
        Top.LaneFlags |= IsVcGreaterEqual;
      } else {
        Top.LaneFlags &= IsVcGreaterEqual;
      }
      FlagStack.ReplaceTop(Top);
    }
  }
}
```

Supporting definitions:
```c
#define SFPLE_MOD1_SET_CC       1
#define SFPLE_MOD1_MUTATE_STACK 2
#define SFPLE_MOD1_MUTATE_OR    4
#define SFPLE_MOD1_SET_VD       8

bool SignMagIsSmaller(uint32_t C, uint32_t D) {
  // This treats C and D as sign-magnitude integers and determines
  // whether C is less than D. If C and D are instead FP32, this
  // still determines whether C is less than D, using the total
  // order where -NaN < -Inf < ... < -0 < +0 < ... < +Inf < +NaN.

  // For purposes of exposition, remap sign-mag -0 ... -(2^31-1)
  // to two's-comp -1 ... -2^31, then perform two's-comp comparison.
  C ^= (uint32_t)((int32_t)C >> 30) >> 1;
  D ^= (uint32_t)((int32_t)D >> 30) >> 1;
  return (int32_t)C < (int32_t)D;
}
```