summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-01-22 16:06:32 -0700
committerKarl Williamson <khw@cpan.org>2020-01-23 15:55:24 -0700
commitc3ee6e27c2c06543aeaeba21f2516ad52cfbd1b2 (patch)
tree041c4ad0b5d3b95a1749c5e5ca68fd347d7ffcfa /numeric.c
parentefc92487e399906bf9520deb444b349cbe03f4f0 (diff)
downloadperl-c3ee6e27c2c06543aeaeba21f2516ad52cfbd1b2.tar.gz
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
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c16
1 files changed, 8 insertions, 8 deletions
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)) {