fabs

Vector Floating-Point Absolute Value

FABS <Vd>.<T>, <Vn>.<T>

Calculates absolute value for each element.

Details

Clears the sign bit of each floating-point element in the source vector, placing the absolute value in the destination vector. This is a bit-level operation that does not signal floating-point exceptions. Available in 32-bit and 64-bit floating-point forms (sz controls element width) on AArch64 with NEON/ASIMD extension.

Pseudocode Operation

for i = 0 to elements_in_vector-1:
  element_size = 32 if sz==0 else 64
  Vd[element][element_size-1:0] = Vn[element][element_size-2:0] || 0

Example

FABS v0.4s.T, v1.4s.T

Encoding

Binary Layout
0
Q
0
011101
sz
10000
01111
10
Rn
Rd
 
Format SIMD Two Register
Opcode 0x0EA0F800
Extension NEON (SIMD)

Operands

  • Vd
    Destination SIMD/FP vector register
  • Vn
    First source SIMD/FP vector register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x0EF8F800 FABS <Vd>.<T>, <Vn>.<T> A64 0 | Q | 0 | 01110 | 1 | 111100 | 01111 | 10 | Rn | Rd
0x0EA0F800 FABS <Vd>.<T>, <Vn>.<T> A64 0 | Q | 0 | 011101 | sz | 10000 | 01111 | 10 | Rn | Rd
0x1EE0C000 FABS <Hd>, <Hn> A64 0 | 0 | 0 | 11110 | 11 | 10000 | 01 | 10000 | Rn | Rd
0x1E20C000 FABS <Sd>, <Sn> A64 0 | 0 | 0 | 11110 | 00 | 10000 | 01 | 10000 | Rn | Rd
0x1E60C000 FABS <Dd>, <Dn> A64 0 | 0 | 0 | 11110 | 01 | 10000 | 01 | 10000 | Rn | Rd
0x041CA000 FABS <Zd>.<T>, <Pg>/M, <Zn>.<T> A64 00000100 | size | 011 | 10 | 0 | 101 | Pg | Zn | Zd

Description

Floating-point Absolute value (vector). This instruction calculates the absolute value of each vector element in the source SIMD&FP register, writes the result to a vector, and writes the vector to the destination SIMD&FP register. Depending on the settings in the CPACR_EL1, CPTR_EL2, and CPTR_EL3 registers, and the current Security state and Exception level, an attempt to execute the instruction might be trapped.

Operation

CheckFPAdvSIMDEnabled64();
bits(datasize) operand = V[n, datasize];
bits(datasize) result;
bits(esize) element;

for e = 0 to elements-1
    element = Elem[operand, e, esize];
    if neg then
        element = FPNeg(element, FPCR);
    else
        element = FPAbs(element, FPCR);
    Elem[result, e, esize] = element;

V[d, datasize] = result;