sunpkhi

SVE Signed Unpack High

SUNPKHI <Zd>.<T>, <Zn>.<Tb>

Unpacks and sign-extends upper half of vector elements.

Details

Unpacks the upper half of each source element and sign-extends it to the destination element size in SVE vectors. No condition flags are affected. This instruction is AArch64-only and available with the SVE extension; destination elements are twice the width of source elements, with sign extension applied to the upper elements.

Pseudocode Operation

for i = 0 to VL/esize_dst-1
  Zd[i+1:i] ← sign_extend(Zn[i+esize_src-1:i+esize_src/2], esize_dst)

Example

SUNPKHI z0.s.T, z1.s.Tb

Encoding

Binary Layout
00000101
size
1100
0
1
001110
Zn
Zd
 
Format SVE Permute
Opcode 0x05313800
Extension SVE

Operands

  • Zd
    Destination scalable vector register (SVE)
  • Zn
    First source scalable vector register (SVE)

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x05313800 SUNPKHI <Zd>.<T>, <Zn>.<Tb> A64 00000101 | size | 1100 | 0 | 1 | 001110 | Zn | Zd

Description

Unpack elements from the lowest or highest half of the source vector and then sign-extend them to place in elements of twice their size within the destination vector. This instruction is unpredicated.

Operation

CheckSVEEnabled();
constant integer VL = CurrentVL;
constant integer PL = VL DIV 8;
constant integer elements = VL DIV esize;
constant integer hsize = esize DIV 2;
bits(VL) operand = Z[n, VL];
bits(VL) result;

for e = 0 to elements-1
    bits(hsize) element = if hi then Elem[operand, e + elements, hsize] else Elem[operand, e, hsize];
    Elem[result, e, esize] = Extend(element, esize, unsigned);

Z[d, VL] = result;