aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-03-05 10:20:33 +0100
committerBjörn Gustavsson <[email protected]>2019-03-06 15:42:43 +0100
commit9e18956fcb279d33ae00d82db7382b81bad7dcc2 (patch)
treec4070c67896210b06436fd238a3e7468e1f09cb3 /erts/emulator
parent405aca76c4bbc47352788858bf0c0749fb1f730d (diff)
downloadotp-9e18956fcb279d33ae00d82db7382b81bad7dcc2.tar.gz
otp-9e18956fcb279d33ae00d82db7382b81bad7dcc2.tar.bz2
otp-9e18956fcb279d33ae00d82db7382b81bad7dcc2.zip
Optimize multiplication in binary matching instructions
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/bs_instrs.tab9
1 files changed, 8 insertions, 1 deletions
diff --git a/erts/emulator/beam/bs_instrs.tab b/erts/emulator/beam/bs_instrs.tab
index 10f43cd786..493ec10222 100644
--- a/erts/emulator/beam/bs_instrs.tab
+++ b/erts/emulator/beam/bs_instrs.tab
@@ -23,10 +23,17 @@
BS_SAFE_MUL(A, B, Fail, Dst) {
Uint a = $A;
Uint b = $B;
- Uint res = a * b;
+ Uint res;
+#ifdef HAVE_OVERFLOW_CHECK_BUILTINS
+ if (__builtin_mul_overflow(a, b, &res)) {
+ $Fail;
+ }
+#else
+ res = a * b;
if (res / b != a) {
$Fail;
}
+#endif
$Dst = res;
}