fneg

Floating-Point Negate (Half-Precision)

FNEG <Vd>.8H, <Vn>.8H

Negates half-precision vector.

Details

Negates each half-precision floating-point element in Vn by flipping the sign bit, writing results to Vd. Operates on 8 half-precision (16-bit) values in a 128-bit vector; this is a bitwise operation that does not raise floating-point exceptions. No condition flags are affected. Requires FEAT_FP16 extension; AArch64-only.

Pseudocode Operation

for i = 0 to 7
  Vd[i*16 +: 16] ← Vn[i*16 +: 16] XOR 0x8000

Example

FNEG v0.4s.8H, v1.4s.8H

Encoding

Binary Layout
0
Q
1
01110
1
111100
01111
10
Rn
Rd
 
Format NEON FP16
Opcode 0x2EF8F800
Extension FEAT_FP16 (NEON)

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
0x2EF8F800 FNEG <Vd>.<T>, <Vn>.<T> A64 0 | Q | 1 | 01110 | 1 | 111100 | 01111 | 10 | Rn | Rd
0x2EA0F800 FNEG <Vd>.<T>, <Vn>.<T> A64 0 | Q | 1 | 011101 | sz | 10000 | 01111 | 10 | Rn | Rd
0x1EE14000 FNEG <Hd>, <Hn> A64 0 | 0 | 0 | 11110 | 11 | 10000 | 10 | 10000 | Rn | Rd
0x1E214000 FNEG <Sd>, <Sn> A64 0 | 0 | 0 | 11110 | 00 | 10000 | 10 | 10000 | Rn | Rd
0x1E614000 FNEG <Dd>, <Dn> A64 0 | 0 | 0 | 11110 | 01 | 10000 | 10 | 10000 | Rn | Rd
0x041DA000 FNEG <Zd>.<T>, <Pg>/M, <Zn>.<T> A64 00000100 | size | 011 | 10 | 1 | 101 | Pg | Zn | Zd

Description

Floating-point Negate (vector). This instruction negates the 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;