From a96b539e748ff9b8ea239f08e02434bbef2e5df1 Mon Sep 17 00:00:00 2001 From: zherczeg Date: Sun, 28 May 2017 03:53:09 +0000 Subject: [PATCH] JIT SSE2 optimization improvement. --- src/pcre2_jit_compile.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index fbbc47a..7f9a714 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -4839,7 +4839,7 @@ if (common->match_end_ptr != 0) static BOOL check_fast_forward_char_pair_sse2(compiler_common *common, fast_forward_char_data *chars, int max) { -sljit_s32 i, priority, left, count; +sljit_s32 i, j, priority, count; sljit_u32 priorities; PCRE2_UCHAR a1, a2, b1, b2; @@ -4865,25 +4865,33 @@ for (priority = 7; priority > 2; priority--) if ((priorities & (1 << priority)) == 0) continue; - left = -1; - - for (i = 0; i < max; i++) + for (i = max - 1; i >= 1; i--) if (chars[i].last_count >= priority) { SLJIT_ASSERT(chars[i].count <= 2 && chars[i].count >= 1); - b1 = chars[i].chars[0]; - b2 = chars[i].chars[1]; + a1 = chars[i].chars[0]; + a2 = chars[i].chars[1]; - if (left >= 0 && i - left <= max_fast_forward_char_pair_sse2_offset() && a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2) + j = i - max_fast_forward_char_pair_sse2_offset(); + if (j < 0) + j = 0; + + while (j < i) { - fast_forward_char_pair_sse2(common, i, b1, b2, left, a1, a2); - return TRUE; - } + if (chars[j].last_count >= priority) + { + b1 = chars[j].chars[0]; + b2 = chars[j].chars[1]; - left = i; - a1 = b1; - a2 = b2; + if (a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2) + { + fast_forward_char_pair_sse2(common, i, a1, a2, j, b1, b2); + return TRUE; + } + } + j++; + } } }