aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/ops.tab
diff options
context:
space:
mode:
authorMichał Muskała <[email protected]>2017-08-26 15:15:01 +0200
committerMichał Muskała <[email protected]>2017-09-08 01:49:10 +0200
commitf9a323d10a9f5da305cbdec632d6bdf7ad4770b5 (patch)
tree7c71ba5bf06ea9b13f3846f05a767be19895399d /erts/emulator/beam/ops.tab
parent5d124efc4f8408cdbe2f23ca6b233b932f1dd7c6 (diff)
downloadotp-f9a323d10a9f5da305cbdec632d6bdf7ad4770b5.tar.gz
otp-f9a323d10a9f5da305cbdec632d6bdf7ad4770b5.tar.bz2
otp-f9a323d10a9f5da305cbdec632d6bdf7ad4770b5.zip
Optimise equality comparisons
* In both loader and compiler, make sure constants are always the second operand - many passes of the compiler assume that's always the case. * In loader rewrite is_eq_exact with same arguments to skip the instruction and with different constants move one to an x register to maintain the properly outlined above. * The same (but in reverse) is done with the is_ne_exact, where we rewrite to an unconditional jump or add a move to an x register. * All of the above allow to replace is_eq_exact_fss with is_eq_exact_fyy and is_ne_exact_fss with is_ne_exact_fSS as those are the only possibilities left.
Diffstat (limited to 'erts/emulator/beam/ops.tab')
-rw-r--r--erts/emulator/beam/ops.tab17
1 files changed, 13 insertions, 4 deletions
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab
index b6e995fdbe..ba0aa005c9 100644
--- a/erts/emulator/beam/ops.tab
+++ b/erts/emulator/beam/ops.tab
@@ -413,9 +413,18 @@ send
# Optimized comparisons with one immediate/literal operand.
#
-is_eq_exact Lbl R=xy C=ian => i_is_eq_exact_immed Lbl R C
+is_eq_exact Lbl S S =>
+is_eq_exact Lbl C1=c C2=c => move C1 x | is_eq_exact Lbl x C2
+is_eq_exact Lbl C=c R=xy => is_eq_exact Lbl R C
+
+is_eq_exact Lbl R=xy n => is_nil Lbl R
+is_eq_exact Lbl R=xy C=ia => i_is_eq_exact_immed Lbl R C
is_eq_exact Lbl R=xy C=q => i_is_eq_exact_literal Lbl R C
+is_ne_exact Lbl S S => jump Lbl
+is_ne_exact Lbl C1=c C2=c => move C1 x | is_ne_exact Lbl x C2
+is_ne_exact Lbl C=c R=xy => is_ne_exact Lbl R C
+
is_ne_exact Lbl R=xy C=ian => i_is_ne_exact_immed Lbl R C
is_ne_exact Lbl R=xy C=q => i_is_ne_exact_literal Lbl R C
@@ -429,7 +438,9 @@ i_is_ne_exact_literal f xy c
is_eq_exact Lbl Y=y X=x => is_eq_exact Lbl X Y
is_eq_exact f x xy
-is_eq_exact f s s
+is_eq_exact f y y
+
+is_ne_exact f S S
is_lt f x x
is_lt f x c
@@ -445,8 +456,6 @@ is_ge f c x
is_ge f s s
%hot
-is_ne_exact f s s
-
is_eq f s s
is_ne f s s