Skip to content

Commit

Permalink
Add vbitsel
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 11, 2023
1 parent 0afaa09 commit 7b0cab0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
42 changes: 4 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,17 @@
# LoongArch SIMD 指令非官网文档
# Unofficial LoongArch Intrinsics Guide

从 QEMU 实现中整理。
Visit <http://jia.je/unofficial-loongarch-intrinsics-guide/>

GCC Intrinsic: <https://gcc.gnu.org/onlinedocs/gcc/LoongArch-SX-Vector-Intrinsics.html>
Arranged from QEMU implementation and [GCC Intrinsics](https://gcc.gnu.org/onlinedocs/gcc/LoongArch-SX-Vector-Intrinsics.html)

## LSX

### vfmadd.s/d

Vector Fused Multiply Add (`a * b + c`) Single/Double Precision

- Single Precision: `__m128 __lsx_vfmadd_s (__m128 a, __m128 b, __m128 c)`
- Double Precision: `__m128d __lsx_vfmadd_d (__m128d a, __m128d b, __m128d c)`

### vfmsub.s/d

Vector Fused Multiply Subtract (`a * b - c`) Single/Double Precision

- Single Precision: `__m128 __lsx_vfmsub_s (__m128 a, __m128 b, __m128 c)`
- Double Precision: `__m128d __lsx_vfmsub_d (__m128d a, __m128d b, __m128d c)`

### vfnmadd.s/d

Vector Fused Negative Multiply Add (`- a * b - c`) Single/Double Precision

- Single Precision: `__m128 __lsx_vfnmadd_s (__m128 a, __m128 b, __m128 c)`
- Double Precision: `__m128d __lsx_vfnmadd_d (__m128d a, __m128d b, __m128d c)`

### vfnmsub.s/d

Vector Fused Negative Multiply Subtract (`- a * b + c`) Single/Double Precision

- Single Precision: `__m128 __lsx_vfnmsub_s (__m128 a, __m128 b, __m128 c)`
- Double Precision: `__m128d __lsx_vfnmsub_d (__m128d a, __m128d b, __m128d c)`
TODO List:

### vfcmp.cond.s/d

Vector Float Compare

<cmp>: See fcmp.cond.s/d instruction

### vbitsel.v

Vector Bit Selection: For each bit, `c ? b : a`

`__m128i __lsx_vbitsel_v (__m128i a, __m128i b, __m128i c)`

### vshuf.b

Vector Shuffle
Expand Down
24 changes: 24 additions & 0 deletions docs/lsx_bitops/vbitsel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Bitwise Selection

## __m128d __lsx_vfnmsub_d (__m128d a, __m128d b, __m128d c)

### Synopsis

```c++
__m128i __lsx_vbitsel_v (__m128i a, __m128i b, __m128i c)
#include <lsxintrin.h>
Instruction: vbitsel.v vr, vr, vr
CPU Flags: LSX
```
### Description
Compute bitwise selection: for each bit position, if the bit in `c` equals to one, copy the bit from `b` to `dst`, otherwise copy from `a`.
### Operation
```c++
for (int i = 0;i < 128;i++) {
dst.bit[i] = a.bit[i] ? b.bit[i] : c.bit[i];
}
```

0 comments on commit 7b0cab0

Please sign in to comment.