fabs
SVE Floating-Point Absolute Value
FABS <Zdn>.<T>, <Pg>/M, <Zdn>.<T>
Calculates absolute value of floats.
Pseudocode Operation
for i = 0 to VL-1
if Pg[i] == '1' then
Zdn[i] ← FPAbs(Zdn[i])
// else Zdn[i] unchanged
Example
FABS z0.s.T, p0/m/M, z0.s.T
Encoding
Binary Layout
00000100
31:24
size
23:22
011
21:19
10
18:17
0
16
101
15:13
Pg
12:10
Zn
9:5
Zd
4:0
Operands
-
Zdn
Combined destination/source scalable vector register (SVE) -
Pg
Mask
Reference
View in Arm A64 ISA 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
Take the absolute value of each active floating-point element of the source vector, and place the results in the corresponding elements of the destination vector. This clears the sign bit and cannot signal a floating-point exception. 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] = FPAbs(element, FPCR);
Z[d, VL] = result;