diff --git a/src/arm64.cpp b/src/arm64.cpp index 2ece3784e..436757d53 100644 --- a/src/arm64.cpp +++ b/src/arm64.cpp @@ -108,10 +108,10 @@ simdjson_unused simdjson_inline simd8 must_be_continuation(const simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2 >= uint8_t(0xe0u); - simd8 is_fourth_byte = prev3 >= uint8_t(0xf0u); - return is_third_byte ^ is_fourth_byte; +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { + simd8 is_third_byte = prev2.saturating_sub(0xe0u-0x80); // Only 111_____ will be >= 0x80 + simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-0x80); // Only 1111____ will be >= 0x80 + return is_third_byte | is_fourth_byte; } } // unnamed namespace diff --git a/src/generic/dom_parser_implementation.h b/src/generic/dom_parser_implementation.h index 9ec3fe8c0..20f7813fc 100644 --- a/src/generic/dom_parser_implementation.h +++ b/src/generic/dom_parser_implementation.h @@ -11,7 +11,7 @@ namespace simdjson { namespace SIMDJSON_IMPLEMENTATION { namespace { -simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3); +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3); simdjson_inline bool is_ascii(const simd8x64& input); } // unnamed namespace diff --git a/src/generic/stage1/utf8_lookup4_algorithm.h b/src/generic/stage1/utf8_lookup4_algorithm.h index 64578915a..1a196159b 100644 --- a/src/generic/stage1/utf8_lookup4_algorithm.h +++ b/src/generic/stage1/utf8_lookup4_algorithm.h @@ -107,7 +107,7 @@ using namespace simd; const simd8 prev_input, const simd8 sc) { simd8 prev2 = input.prev<2>(prev_input); simd8 prev3 = input.prev<3>(prev_input); - simd8 must23 = simd8(must_be_2_3_continuation(prev2, prev3)); + simd8 must23 = must_be_2_3_continuation(prev2, prev3); simd8 must23_80 = must23 & uint8_t(0x80); return must23_80 ^ sc; } diff --git a/src/haswell.cpp b/src/haswell.cpp index 5eec137aa..f721cac8b 100644 --- a/src/haswell.cpp +++ b/src/haswell.cpp @@ -105,11 +105,10 @@ simdjson_unused simdjson_inline simd8 must_be_continuation(const simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0xe0u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { + simd8 is_third_byte = prev2.saturating_sub(0xe0u-0x80); // Only 111_____ will be >= 0x80 + simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-0x80); // Only 1111____ will be >= 0x80 + return is_third_byte | is_fourth_byte; } } // unnamed namespace diff --git a/src/icelake.cpp b/src/icelake.cpp index 92c7d2faf..8ec08c69c 100644 --- a/src/icelake.cpp +++ b/src/icelake.cpp @@ -107,11 +107,10 @@ simdjson_unused simdjson_inline simd8 must_be_continuation(const simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0xe0u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { + simd8 is_third_byte = prev2.saturating_sub(0xe0u-0x80); // Only 111_____ will be >= 0x80 + simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-0x80); // Only 1111____ will be >= 0x80 + return is_third_byte | is_fourth_byte; } } // unnamed namespace diff --git a/src/ppc64.cpp b/src/ppc64.cpp index 769164c17..63606380c 100644 --- a/src/ppc64.cpp +++ b/src/ppc64.cpp @@ -78,11 +78,10 @@ simdjson_unused simdjson_inline simd8 must_be_continuation(const simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0xe0u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { + simd8 is_third_byte = prev2.saturating_sub(0xe0u-0x80); // Only 111_____ will be >= 0x80 + simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-0x80); // Only 1111____ will be >= 0x80 + return is_third_byte | is_fourth_byte; } } // unnamed namespace diff --git a/src/westmere.cpp b/src/westmere.cpp index 45d5e2c3f..538db42f8 100644 --- a/src/westmere.cpp +++ b/src/westmere.cpp @@ -109,11 +109,10 @@ simdjson_unused simdjson_inline simd8 must_be_continuation(const simd8(is_second_byte | is_third_byte | is_fourth_byte) > int8_t(0); } -simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { - simd8 is_third_byte = prev2.saturating_sub(0xe0u-1); // Only 111_____ will be > 0 - simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-1); // Only 1111____ will be > 0 - // Caller requires a bool (all 1's). All values resulting from the subtraction will be <= 64, so signed comparison is fine. - return simd8(is_third_byte | is_fourth_byte) > int8_t(0); +simdjson_inline simd8 must_be_2_3_continuation(const simd8 prev2, const simd8 prev3) { + simd8 is_third_byte = prev2.saturating_sub(0xe0u-0x80); // Only 111_____ will be >= 0x80 + simd8 is_fourth_byte = prev3.saturating_sub(0xf0u-0x80); // Only 1111____ will be >= 0x80 + return is_third_byte | is_fourth_byte; } } // unnamed namespace