simdjson 4.1.0
Ridiculously Fast JSON
Loading...
Searching...
No Matches
bitmask.h
1#ifndef SIMDJSON_ARM64_BITMASK_H
2#define SIMDJSON_ARM64_BITMASK_H
3
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#include "simdjson/arm64/base.h"
6#endif // SIMDJSON_CONDITIONAL_INCLUDE
7
8namespace simdjson {
9namespace arm64 {
10namespace {
11
12//
13// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.
14//
15// For example, prefix_xor(00100100) == 00011100
16//
17simdjson_inline uint64_t prefix_xor(uint64_t bitmask) {
19 // We could do this with PMULL, but it is apparently slow.
20 //
21 //#ifdef __ARM_FEATURE_CRYPTO // some ARM processors lack this extension
22 //return vmull_p64(-1ULL, bitmask);
23 //#else
24 // Analysis by @sebpop:
25 // When diffing the assembly for src/stage1_find_marks.cpp I see that the eors are all spread out
26 // in between other vector code, so effectively the extra cycles of the sequence do not matter
27 // because the GPR units are idle otherwise and the critical path is on the FP side.
28 // Also the PMULL requires two extra fmovs: GPR->FP (3 cycles in N1, 5 cycles in A72 )
29 // and FP->GPR (2 cycles on N1 and 5 cycles on A72.)
31 bitmask ^= bitmask << 1;
32 bitmask ^= bitmask << 2;
33 bitmask ^= bitmask << 4;
34 bitmask ^= bitmask << 8;
35 bitmask ^= bitmask << 16;
36 bitmask ^= bitmask << 32;
37 return bitmask;
38}
39
40} // unnamed namespace
41} // namespace arm64
42} // namespace simdjson
43
44#endif
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8