abs

SVE Absolute Value

ABS <Zdn>.<T>, <Pg>/M, <Zdn>.<T>

Calculates absolute value of integers.

Pseudocode Operation

for e = 0 to VL/getElementSize(T)-1
  if Pg[e] == 1 then
    Zdn[e] ← abs_signed(Zdn[e])
  end if
end for

Example

ABS z0.s.T, p0/m/M, z0.s.T

Encoding

Binary Layout
00000100
31:24
size
23:22
010
21:19
11
18:17
0
16
101
15:13
Pg
12:10
Zn
9:5
Zd
4:0
 
Format SVE Integer Unary
Opcode 0x0416A000
Extension SVE

Operands

  • Zdn
    Dest/Src
  • Pg
    Mask

Related

Other forms of abs

  • abs Vector Absolute Value

More in SVE

Reference

Instruction Forms

Encoding Instruction ISA Bit pattern
0x5AC02000 ABS <Wd>, <Wn> A64 0 | 1 | 0 | 11010110 | 00000 | 001000 | Rn | Rd
0xDAC02000 ABS <Xd>, <Xn> A64 1 | 1 | 0 | 11010110 | 00000 | 001000 | Rn | Rd
0x5EE0B800 ABS D<d>, D<n> A64 01 | 0 | 11110 | 11 | 10000 | 01011 | 10 | Rn | Rd
0x0E20B800 ABS <Vd>.<T>, <Vn>.<T> A64 0 | Q | 0 | 01110 | size | 10000 | 01011 | 10 | Rn | Rd
0x0416A000 ABS <Zd>.<T>, <Pg>/M, <Zn>.<T> A64 00000100 | size | 010 | 11 | 0 | 101 | Pg | Zn | Zd

Description

Compute the absolute value of the signed integer 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
        integer element = SInt(Elem[operand, e, esize]);
        element = Abs(element);
        Elem[result, e, esize] = element<esize-1:0>;

Z[d, VL] = result;