/src/simdjson/include/simdjson/haswell/numberparsing.h
Line | Count | Source |
1 | | #ifndef SIMDJSON_HASWELL_NUMBERPARSING_H |
2 | | #define SIMDJSON_HASWELL_NUMBERPARSING_H |
3 | | |
4 | | namespace simdjson { |
5 | | namespace SIMDJSON_IMPLEMENTATION { |
6 | | namespace { |
7 | | |
8 | 9.48k | static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) { |
9 | | // this actually computes *16* values so we are being wasteful. |
10 | 9.48k | const __m128i ascii0 = _mm_set1_epi8('0'); |
11 | 9.48k | const __m128i mul_1_10 = |
12 | 9.48k | _mm_setr_epi8(10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1); |
13 | 9.48k | const __m128i mul_1_100 = _mm_setr_epi16(100, 1, 100, 1, 100, 1, 100, 1); |
14 | 9.48k | const __m128i mul_1_10000 = |
15 | 9.48k | _mm_setr_epi16(10000, 1, 10000, 1, 10000, 1, 10000, 1); |
16 | 9.48k | const __m128i input = _mm_sub_epi8( |
17 | 9.48k | _mm_loadu_si128(reinterpret_cast<const __m128i *>(chars)), ascii0); |
18 | 9.48k | const __m128i t1 = _mm_maddubs_epi16(input, mul_1_10); |
19 | 9.48k | const __m128i t2 = _mm_madd_epi16(t1, mul_1_100); |
20 | 9.48k | const __m128i t3 = _mm_packus_epi32(t2, t2); |
21 | 9.48k | const __m128i t4 = _mm_madd_epi16(t3, mul_1_10000); |
22 | 9.48k | return _mm_cvtsi128_si32( |
23 | 9.48k | t4); // only captures the sum of the first 8 digits, drop the rest |
24 | 9.48k | } Unexecuted instantiation: fuzz_ndjson.cpp:simdjson::haswell::(anonymous namespace)::parse_eight_digits_unrolled(unsigned char const*) simdjson.cpp:simdjson::haswell::(anonymous namespace)::parse_eight_digits_unrolled(unsigned char const*) Line | Count | Source | 8 | 9.48k | static simdjson_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars) { | 9 | | // this actually computes *16* values so we are being wasteful. | 10 | 9.48k | const __m128i ascii0 = _mm_set1_epi8('0'); | 11 | 9.48k | const __m128i mul_1_10 = | 12 | 9.48k | _mm_setr_epi8(10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1); | 13 | 9.48k | const __m128i mul_1_100 = _mm_setr_epi16(100, 1, 100, 1, 100, 1, 100, 1); | 14 | 9.48k | const __m128i mul_1_10000 = | 15 | 9.48k | _mm_setr_epi16(10000, 1, 10000, 1, 10000, 1, 10000, 1); | 16 | 9.48k | const __m128i input = _mm_sub_epi8( | 17 | 9.48k | _mm_loadu_si128(reinterpret_cast<const __m128i *>(chars)), ascii0); | 18 | 9.48k | const __m128i t1 = _mm_maddubs_epi16(input, mul_1_10); | 19 | 9.48k | const __m128i t2 = _mm_madd_epi16(t1, mul_1_100); | 20 | 9.48k | const __m128i t3 = _mm_packus_epi32(t2, t2); | 21 | 9.48k | const __m128i t4 = _mm_madd_epi16(t3, mul_1_10000); | 22 | 9.48k | return _mm_cvtsi128_si32( | 23 | 9.48k | t4); // only captures the sum of the first 8 digits, drop the rest | 24 | 9.48k | } |
|
25 | | |
26 | | } // unnamed namespace |
27 | | } // namespace SIMDJSON_IMPLEMENTATION |
28 | | } // namespace simdjson |
29 | | |
30 | | #define SIMDJSON_SWAR_NUMBER_PARSING 1 |
31 | | |
32 | | #include "simdjson/generic/numberparsing.h" |
33 | | |
34 | | #endif // SIMDJSON_HASWELL_NUMBERPARSING_H |