This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-10-quiet-head
in repository terminology.
View the commit online.
commit 9a0db5b169b99706402fee846962960993a9c23d
Author: [email protected] <[email protected]>
AuthorDate: Sun Oct 25 13:31:20 2026 -0600
simd: fix the SSE2 u32 scan comments and test their edge cases
The comments of simd_scan_plain_ascii_u32_sse2() said that the wrap of
g - 0x20 is caught by the sign bit of the subtraction, and that negative
values had already failed the signed compare. Neither holds for
g in 0x80000000..0x8000001f: g - 0x20 lands in 0x7fffffe0..0x7fffffff,
with the sign bit clear, and the signed compare against 0x7e is false
because g itself is negative. The kernel is still correct, but only
because _mm_movemask_epi8() also takes the top bit of the low byte
(0xe0..0xff). The comments now describe what actually flags each range.
The kernel itself is unchanged.
The codepoint boundary values of the parity test gain 0x7fffffff,
0x8000001f, 0x80000020 and 0xffffffff, the edges of the ranges that
depend on bits other than the sign bit. Previously only 0x80000000 was
covered. The test is shared with the NEON kernel.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013EAviPfxPDDoPwP4mjK41P
---
src/bin/simd/simd.c | 3 ++-
src/bin/simd/simd_sse2.c | 19 ++++++++++---------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/bin/simd/simd.c b/src/bin/simd/simd.c
index ffa9adaa..ed4c0fe9 100644
--- a/src/bin/simd/simd.c
+++ b/src/bin/simd/simd.c
@@ -663,7 +663,8 @@ _test_every_u32_boundary(void)
{
static const Eina_Unicode vals[] = {
0x00, 0x01, 0x1f, 0x20, 0x21, 0x7d, 0x7e, 0x7f, 0x80, 0xa0,
- 0x200b, 0x300, 0x4e2d, 0xfe00, 0x1f600, 0x80000000u
+ 0x200b, 0x300, 0x4e2d, 0xfe00, 0x1f600, 0x7fffffffu, 0x80000000u,
+ 0x8000001fu, 0x80000020u, 0xffffffffu
};
size_t v, len, pos, i;
diff --git a/src/bin/simd/simd_sse2.c b/src/bin/simd/simd_sse2.c
index d2c6965e..33deb48a 100644
--- a/src/bin/simd/simd_sse2.c
+++ b/src/bin/simd/simd_sse2.c
@@ -42,12 +42,9 @@ simd_scan_plain_ascii_sse2(const unsigned char *buf, size_t len)
size_t
simd_scan_plain_ascii_u32_sse2(const Eina_Unicode *buf, size_t len)
{
- /* One unsigned compare instead of two: g - 0x20 wraps for anything below
- * 0x20, pushing it above the 0x5e span that 0x20..0x7e occupies. SSE2 has
- * no unsigned compare, so the wrap is caught by the sign bit of the
- * subtraction and the span by a signed compare: every g that is unsigned
- * greater than 0x7e is either signed greater than 0x7e or negative, and
- * negatives already failed the first test. */
+ /* SSE2 has no unsigned compare: a wrapping subtraction folds g < 0x20
+ * and g >= 0x80000000 into values with a byte whose top bit is set, and a
+ * signed compare takes the rest of g >= 0x7f. */
const __m128i bias = _mm_set1_epi32(0x20);
const __m128i span = _mm_set1_epi32(0x7e);
size_t i = 0;
@@ -57,9 +54,13 @@ simd_scan_plain_ascii_u32_sse2(const Eina_Unicode *buf, size_t len)
__m128i v = _mm_loadu_si128((const __m128i *)(buf + i));
__m128i under = _mm_sub_epi32(v, bias);
__m128i over = _mm_cmpgt_epi32(v, span);
- /* movemask maps byte lanes to bits, so lane k owns bits 4k..4k+3:
- * 4k+3 from the sign of the subtraction, 4k..4k+2 from the compare.
- * The lowest set bit is the first offending lane. */
+ /* movemask keeps the top bit of every byte, so lane k owns bits
+ * 4k..4k+3 and the lowest set bit gives the first offending lane
+ * through ctz >> 2. 'over' sets all four bits of a lane for
+ * 0x7f..0x7fffffff. 'under' catches the rest: g - 0x20 has a byte
+ * with its top bit set for every g below 0x20 and every g from
+ * 0x80000000 up (the low byte for 0x80000000..0x8000001f, the high
+ * byte beyond), while it is below 0x80 in every byte for 0x20..0x7e. */
unsigned int m = (unsigned int)(_mm_movemask_epi8(under) |
_mm_movemask_epi8(over));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.