Instruction
T1MSKC
Makes a mask of the trailing ones of the source, inverted (~x | (x + 1)); TBM.
An AMD extension: Intel processors do not have this instruction.
- Extensions
- Forms
- 4 (4 XOP)
- Data
- Intel XED v2026.08.23
Forms
| Instruction | Encoding | Requires |
|---|---|---|
T1MSKC r32, m32 not in 64-bit mode
T1MSKC_GPR32d_MEMd | XOP.LZ.NP.09.WIG 01 /7 | TBM |
T1MSKC r32/64, m32/64 64-bit mode only
T1MSKC_GPRyy_MEMy | XOP.LZ.NP.09.WIG 01 /7 | TBM |
T1MSKC r32, r32 not in 64-bit mode
T1MSKC_GPR32d_GPR32d | XOP.LZ.NP.09.WIG 01 /7 | TBM |
T1MSKC r32/64, r32/64 64-bit mode only
T1MSKC_GPRyy_GPRyy | XOP.LZ.NP.09.WIG 01 /7 | TBM |
Latency and throughput
| Model | r32/64, m32/64 | r32/64, r32/64 |
|---|---|---|
| Piledriver | 6 / 1.5EX0 EX1 | 2 / 1EX0 EX1 |
| Zen | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 2 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
features = cpuid_leaf(0x80000001, 0)[2]
if not features >> 21 & 1:
fault(UD) # CPUID: no TBM
s = src.read()
t = s + 1
r = low(~s | t) # zeros for the trailing 1 bits, ones
# above them
cf = t >> OSIZE # 1 when src is all ones
sf = msb(r)
zf = r == 0
of = 0
af = pf = UNDEFINED
dest.write(r) # a 32-bit register: bits 63:32 cleared
Run on AMD Zen 5 (EPYC 9645): 4 cases. Its cases ran where CPUID reported no TBM, and every one raised an exception. The forms that 64-bit mode lacks were not run: the probe runs in 64-bit mode.
Operands
| Operand | Kind | Action |
|---|---|---|
T1MSKC r32, r/m32 not in 64-bit mode T1MSKC r32/64, r/m32/64 64-bit mode only | ||
r32/64 | explicit | write |
r/m32/64 | explicit | read |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| 0 | M | M | U | U | M |
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to T1MSKC, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
__t1mskc_u32
unsigned int __t1mskc_u32(unsigned int __a) |
|
__t1mskc_u64
unsigned long long __t1mskc_u64(unsigned long long __a) |
|
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
TBM | TBM | Piledriver, Zen, Zen+, Zen 2 Note: XED's Zen chips inherit TBM from its Piledriver chip; GCC's -march=znver1 and later do not enable TBM. |
More TBM instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.38, July 2026)
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.