Skip to content

Commit

Permalink
Add vbitseli.b
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 12, 2023
1 parent 73780f3 commit 6f3a1bf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ Vector Multiplication High

### vshuf4i.b/h/w/d

### vbitseli.b

### vori.b

### vxori.b
Expand Down
15 changes: 15 additions & 0 deletions code/vbitseli_b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"

v128 vbitseli_b(v128 a, v128 b, int imm) {
v128 dst;
#include "vbitseli_b.h"
return dst;
}

void test() {
FUZZ2(vbitseli_b, 0x00);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x01);
FUZZ2(vbitseli_b, 0x80);
FUZZ2(vbitseli_b, 0xFF);
}
3 changes: 3 additions & 0 deletions code/vbitseli_b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for (int i = 0; i < 16; i++) {
dst.byte[i] = (~a.byte[i] & b.byte[i]) | (a.byte[i] & (u8)imm);
}
21 changes: 21 additions & 0 deletions docs/lsx_bitops/vbitwise.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ Compute bitwise selection: for each bit position, if the bit in `c` equals to on
{% include 'vbitsel_v.h' %}
```

## __m128i __lsx_vbitseli_b (__m128i a, __m128i b, imm0_255 imm)

### Synopsis

```c++
__m128i __lsx_vbitseli_b (__m128i a, __m128i b, imm0_255 imm)
#include <lsxintrin.h>
Instruction: vbitseli.b vr, vr, imm
CPU Flags: LSX
```
### Description
Compute bitwise selection: for each bit position, if the bit in `a` equals to one, copy the bit from `imm` to `dst`, otherwise copy from `b`.
### Operation
```c++
{% include 'vbitseli_b.h' %}
```

{{ vbitclr('b') }}
{{ vbitclr('h') }}
{{ vbitclr('w') }}
Expand Down

0 comments on commit 6f3a1bf

Please sign in to comment.