simdjson  3.11.0
Ridiculously Fast JSON
bitmask.h
1 #ifndef SIMDJSON_PPC64_BITMASK_H
2 #define SIMDJSON_PPC64_BITMASK_H
3 
4 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
5 #include "simdjson/ppc64/base.h"
6 #endif // SIMDJSON_CONDITIONAL_INCLUDE
7 
8 namespace simdjson {
9 namespace ppc64 {
10 namespace {
11 
12 //
13 // Perform a "cumulative bitwise xor," flipping bits each time a 1 is
14 // encountered.
15 //
16 // For example, prefix_xor(00100100) == 00011100
17 //
18 simdjson_inline uint64_t prefix_xor(uint64_t bitmask) {
19  // You can use the version below, however gcc sometimes miscompiles
20  // vec_pmsum_be, it happens somewhere around between 8 and 9th version.
21  // The performance boost was not noticeable, falling back to a usual
22  // implementation.
23  // __vector unsigned long long all_ones = {~0ull, ~0ull};
24  // __vector unsigned long long mask = {bitmask, 0};
25  // // Clang and GCC return different values for pmsum for ull so cast it to one.
26  // // Generally it is not specified by ALTIVEC ISA what is returned by
27  // // vec_pmsum_be.
28  // #if defined(__LITTLE_ENDIAN__)
29  // return (uint64_t)(((__vector unsigned long long)vec_pmsum_be(all_ones, mask))[0]);
30  // #else
31  // return (uint64_t)(((__vector unsigned long long)vec_pmsum_be(all_ones, mask))[1]);
32  // #endif
33  bitmask ^= bitmask << 1;
34  bitmask ^= bitmask << 2;
35  bitmask ^= bitmask << 4;
36  bitmask ^= bitmask << 8;
37  bitmask ^= bitmask << 16;
38  bitmask ^= bitmask << 32;
39  return bitmask;
40 }
41 
42 } // unnamed namespace
43 } // namespace ppc64
44 } // namespace simdjson
45 
46 #endif
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8