diff options
author | Björn Gustavsson <[email protected]> | 2017-10-21 07:22:47 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-10-21 07:51:45 +0200 |
commit | 19a1af93458ec7a4a252671603d74971f4dec969 (patch) | |
tree | 8ada956d105e99a06fd1ef5f0d7ee4dd1f894304 /erts/emulator | |
parent | 6753bbcc3fdb0dd15c8025902d22dc4ec8c33575 (diff) | |
download | otp-19a1af93458ec7a4a252671603d74971f4dec969.tar.gz otp-19a1af93458ec7a4a252671603d74971f4dec969.tar.bz2 otp-19a1af93458ec7a4a252671603d74971f4dec969.zip |
Optimize instructions for comparing a register with a literal
We can avoid calling eq() from the is_eq_exact_literal/3
and is_ne_exact_literal/3 instructions if the source operand is
an immediate (since a literal is either a boxed or a list, never
an immediate).
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/instrs.tab | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/erts/emulator/beam/instrs.tab b/erts/emulator/beam/instrs.tab index 20d356a81d..c17d1a8f69 100644 --- a/erts/emulator/beam/instrs.tab +++ b/erts/emulator/beam/instrs.tab @@ -788,7 +788,8 @@ is_eq_exact(Fail, X, Y) { } i_is_eq_exact_literal(Fail, Src, Literal) { - if (!eq($Src, $Literal)) { + Eterm src = $Src; + if (is_immed(src) || !eq(src, $Literal)) { $FAIL($Fail); } } @@ -800,7 +801,8 @@ is_ne_exact(Fail, X, Y) { } i_is_ne_exact_literal(Fail, Src, Literal) { - if (eq($Src, $Literal)) { + Eterm src = $Src; + if (!is_immed(src) && eq(src, $Literal)) { $FAIL($Fail); } } |