cls

CLS <Zd>.<T>, <Pg>/M, <Zn>.<T>

Count Leading Sign Bits.

Pseudocode Operation

No pseudocode available.

Encoding

Binary Layout
00000100
31:24
size
23:22
011
21:19
00
18:17
0
16
101
15:13
Pg
12:10
Zn
9:5
Zd
4:0
 
Format SVE
Opcode 0x0418A000
Extension SVE

Related

Other forms of cls

  • cls Count Leading Sign Bits, Base

More in SVE

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0x0E204800 CLS <Vd>.<T>, <Vn>.<T> A64 0 | Q | 0 | 01110 | size | 10000 | 00100 | 10 | Rn | Rd
0x5AC01400 CLS <Wd>, <Wn> A64 0 | 1 | 0 | 11010110 | 00000 | 00010 | 1 | Rn | Rd
0xDAC01400 CLS <Xd>, <Xn> A64 1 | 1 | 0 | 11010110 | 00000 | 00010 | 1 | Rn | Rd
0x0418A000 CLS <Zd>.<T>, <Pg>/M, <Zn>.<T> A64 00000100 | size | 011 | 00 | 0 | 101 | Pg | Zn | Zd

Description

Count the number of consecutive sign bits, starting from the most significant bit in each active element of the source vector, and place the results in the corresponding elements of the destination vector. Inactive elements in the destination vector register remain unmodified.

Operation

CheckSVEEnabled();
constant integer VL = CurrentVL;
constant integer PL = VL DIV 8;
constant integer elements = VL DIV esize;
bits(PL) mask = P[g, PL];
bits(VL) operand = if AnyActiveElement(mask, esize) then Z[n, VL] else Zeros(VL);
bits(VL) result = Z[d, VL];

for e = 0 to elements-1
    if ActivePredicateElement(mask, e, esize) then
        bits(esize) element = Elem[operand, e, esize];
        Elem[result, e, esize] = CountLeadingSignBits(element)<esize-1:0>;

Z[d, VL] = result;