Skip to content

Commit

Permalink
Add vshuf.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 11, 2023
1 parent 820b99c commit 7529e9b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion docs/lsx_misc/vshuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,43 @@ CPU Flags: LSX
Shuffle bytes from `a` and `b` with indices from `c`.
Caveat: the indices are placed in `c`, while in other `vshuf` intrinsics they are placed in `a`.
### Operation
```c++
for (int i = 0;i < 16;i++) {
if (c.byte[i] % 32 < 16) {
if ((c.byte[i] % 32) < 16) {
dst.byte[i] = b.byte[c.byte[i] % 16];
} else {
dst.byte[i] = a.byte[c.byte[i] % 16];
}
}
```

## __m128i __lsx_vshuf_h (__m128i a, __m128i b, __m128i c)

### Synopsis

```c++
__m128i __lsx_vshuf_h (__m128i a, __m128i b, __m128i c)
#include <lsxintrin.h>
Instruction: vshuf.h vr, vr, vr
CPU Flags: LSX
```
### Description
Shuffle half words from `b` and `c` with indices from `a`.
### Operation
```c++
for (int i = 0;i < 8;i++) {
if ((c.half[i] % 16) < 8) {
dst.half[i] = c.half[a.half[i] % 8];
} else {
dst.half[i] = b.half[a.half[i] % 8];
}
}
```

0 comments on commit 7529e9b

Please sign in to comment.