Skip to content

Commit a0771f2

Browse files
committed
Relaxed SIMD.
1 parent 6bad547 commit a0771f2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

sqlite3/libc/string.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,17 @@ char *strrchr(const char *s, int c) {
333333

334334
// http://0x80.pl/notesen/2018-10-18-simd-byte-lookup.html
335335

336-
#define _WASM_SIMD128_BITMAP256_T \
337-
struct { \
338-
uint8_t l __attribute__((__vector_size__(16), __aligned__(16))); \
339-
uint8_t h __attribute__((__vector_size__(16), __aligned__(16))); \
336+
#ifndef __wasm_relaxed_simd__
337+
338+
#define wasm_i8x16_relaxed_laneselect wasm_v128_bitselect
339+
#define wasm_i8x16_relaxed_swizzle wasm_i8x16_swizzle
340+
341+
#endif // __wasm_relaxed_simd__
342+
343+
#define _WASM_SIMD128_BITMAP256_T \
344+
struct { \
345+
__u8x16 l; \
346+
__u8x16 h; \
340347
}
341348

342349
#define _WASM_SIMD128_SETBIT(bitmap, i) \
@@ -367,10 +374,11 @@ char *strrchr(const char *s, int c) {
367374
v128_t _bitmask_lookup = wasm_u8x16_const(1, 2, 4, 8, 16, 32, 64, 128, \
368375
1, 2, 4, 8, 16, 32, 64, 128); \
369376
\
370-
v128_t _bitmask = wasm_i8x16_swizzle(_bitmask_lookup, _hi_nibbles); \
371-
v128_t _bitsets = wasm_v128_bitselect( \
372-
wasm_i8x16_swizzle(bitmap.l, _lo_nibbles), \
373-
wasm_i8x16_swizzle(bitmap.h, _lo_nibbles), \
377+
v128_t _bitmask = \
378+
wasm_i8x16_relaxed_swizzle(_bitmask_lookup, _hi_nibbles); \
379+
v128_t _bitsets = wasm_i8x16_relaxed_laneselect( \
380+
wasm_i8x16_relaxed_swizzle(bitmap.l, _lo_nibbles), \
381+
wasm_i8x16_relaxed_swizzle(bitmap.h, _lo_nibbles), \
374382
wasm_i8x16_lt(_hi_nibbles, wasm_u8x16_const_splat(8))); \
375383
\
376384
wasm_i8x16_eq(_bitsets & _bitmask, _bitmask); \
@@ -458,6 +466,9 @@ size_t strcspn(const char *s, const char *c) {
458466
return s - a;
459467
}
460468

469+
#undef wasm_i8x16_relaxed_laneselect
470+
#undef wasm_i8x16_relaxed_swizzle
471+
461472
#undef _WASM_SIMD128_SETBIT
462473
#undef _WASM_SIMD128_CHKBIT
463474
#undef _WASM_SIMD128_CHKBITS

0 commit comments

Comments
 (0)