__lasx_xvilvh_b

LASX intrinsic · group: Misc

Synopsis

__m256i __lasx_xvilvh_b (__m256i a, __m256i b)
#include <lasxintrin.h>
Instruction: xvilvh.b xr, xr, xr
CPU Flags: LASX

Description

For each 128-bit lane, interleave the 8-bit elements in the upper half of that lane from a and b: the element from b is placed at the even output position and the element from a at the following odd position.

Operation

int i;
for (i = 0; i < 16; i++) {
  dst.byte[i] = (i % 2 == 1) ? a.byte[i / 2 + 8] : b.byte[i / 2 + 8];
}
for (; i < 32; i++) {
  dst.byte[i] = (i % 2 == 1) ? a.byte[i / 2 + 16] : b.byte[i / 2 + 16];
}

// Expands to:

if (0) {
  dst.byte[0] = b.byte[8];
  dst.byte[1] = a.byte[8];
  dst.byte[2] = b.byte[9];
  dst.byte[3] = a.byte[9];
  dst.byte[4] = b.byte[10];
  dst.byte[5] = a.byte[10];
  dst.byte[6] = b.byte[11];
  dst.byte[7] = a.byte[11];
  dst.byte[8] = b.byte[12];
  dst.byte[9] = a.byte[12];
  dst.byte[10] = b.byte[13];
  dst.byte[11] = a.byte[13];
  dst.byte[12] = b.byte[14];
  dst.byte[13] = a.byte[14];
  dst.byte[14] = b.byte[15];
  dst.byte[15] = a.byte[15];
  dst.byte[16] = b.byte[24];
  dst.byte[17] = a.byte[24];
  dst.byte[18] = b.byte[25];
  dst.byte[19] = a.byte[25];
  dst.byte[20] = b.byte[26];
  dst.byte[21] = a.byte[26];
  dst.byte[22] = b.byte[27];
  dst.byte[23] = a.byte[27];
  dst.byte[24] = b.byte[28];
  dst.byte[25] = a.byte[28];
  dst.byte[26] = b.byte[29];
  dst.byte[27] = a.byte[29];
  dst.byte[28] = b.byte[30];
  dst.byte[29] = a.byte[30];
  dst.byte[30] = b.byte[31];
  dst.byte[31] = a.byte[31];
}

Tested on real machine.

Latency and Throughput

CPU µarch Latency Throughput (IPC)
3C5000 LA464 1 2
3A6000 LA664 1 4
3C6000 LA664 1 4

All intrinsics in alphabetical order