From c3ee6e27c2c06543aeaeba21f2516ad52cfbd1b2 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 22 Jan 2020 16:06:32 -0700 Subject: grok_bin_oct_hex: Add some branch predictions This led to about a 7% improvement, number of branches went 2.3kk->1.9kk in perf, thanks to Sergey Aleynikov. cachegrind shows: Key: Ir Instruction read Dr Data read Dw Data write COND conditional branches IND indirect branches _m branch predict miss The numbers represent raw counts per loop iteration. eight_hex_digits 87654321 blead latest Ratio % ----- ------ ------- Ir 306.0 297.0 103.0 Dr 76.0 76.0 100.0 Dw 41.0 39.0 105.1 COND 26.0 26.0 100.0 IND 2.0 2.0 100.0 COND_m 0.1 0.0 Inf IND_m 3.0 3.0 100.0 --- numeric.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 03bc3a34bc..51a0edfbe6 100644 --- a/numeric.c +++ b/numeric.c @@ -429,42 +429,42 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start, case 0: return 0; default: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 7: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 6: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 5: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 4: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 3: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 2: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); s++; /* FALLTHROUGH */ case 1: - if (! _generic_isCC(*s, class_bit)) break; + if (UNLIKELY(! _generic_isCC(*s, class_bit))) break; value = (value << shift) | XDIGIT_VALUE(*s); if (LIKELY(len <= 8)) { -- cgit v1.2.1