diff options
author | Björn Gustavsson <[email protected]> | 2019-03-05 12:10:18 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-03-06 15:42:43 +0100 |
commit | 8eb6e937c4c5aa4c86142f37f1455637f7e8a20a (patch) | |
tree | 326f289f575f85ef721a2a8ebed4d9b92f01e750 /erts/emulator/beam/arith_instrs.tab | |
parent | 9e18956fcb279d33ae00d82db7382b81bad7dcc2 (diff) | |
download | otp-8eb6e937c4c5aa4c86142f37f1455637f7e8a20a.tar.gz otp-8eb6e937c4c5aa4c86142f37f1455637f7e8a20a.tar.bz2 otp-8eb6e937c4c5aa4c86142f37f1455637f7e8a20a.zip |
Optimize the '*' operator when multiplying two small integers
Diffstat (limited to 'erts/emulator/beam/arith_instrs.tab')
-rw-r--r-- | erts/emulator/beam/arith_instrs.tab | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/erts/emulator/beam/arith_instrs.tab b/erts/emulator/beam/arith_instrs.tab index 574fceec5b..5f23b2c168 100644 --- a/erts/emulator/beam/arith_instrs.tab +++ b/erts/emulator/beam/arith_instrs.tab @@ -116,6 +116,17 @@ increment.execute(IncrementVal, Dst) { i_times(Fail, Op1, Op2, Dst) { Eterm op1 = $Op1; Eterm op2 = $Op2; +#ifdef HAVE_OVERFLOW_CHECK_BUILTINS + if (ERTS_LIKELY(is_both_small(op1, op2))) { + Sint a = signed_val(op1); + Sint b = signed_val(op2); + Sint res; + if (ERTS_LIKELY(!__builtin_mul_overflow(a, b, &res) && IS_SSMALL(res))) { + $Dst = make_small(res); + $NEXT0(); + } + } +#endif $OUTLINED_ARITH_2($Fail, mixed_times, BIF_stimes_2, op1, op2, $Dst); } |