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