Skip to content

Commit

Permalink
Implement vbitsel_v
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 12, 2023
1 parent d33827f commit eadb5bd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions code/vbitsel_v.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "common.h"

v128 vbitsel_v(v128 a, v128 b, v128 c) {
v128 dst;
for (int i = 0; i < 2; i++) {
dst.dword[i] = (c.dword[i] & b.dword[i]) | (~c.dword[i] & a.dword[i]);
}
return dst;
}

void test() {
__m128i a = {0x123456789ABCDEF0, 0x0FEDCBA987654321};
__m128i b = {0x1122334455667788, 0x1212343456567878};
Expand All @@ -8,4 +16,14 @@ void test() {
PRINT(b);
PRINT(c);
PRINT(__lsx_vbitsel_v(a, b, c));

for (int i = 0; i < 64; i++) {
v128 a, b, c;
PRINT(a);
PRINT(b);
PRINT(c);
PRINT(__lsx_vbitsel_v(a, b, c));
PRINT(vbitsel_v(a, b, c));
assert(vbitsel_v(a, b, c) == __lsx_vbitsel_v(a, b, c));
}
}

0 comments on commit eadb5bd

Please sign in to comment.