aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-04-07 12:04:11 +0200
committerBjörn Gustavsson <[email protected]>2017-04-07 12:08:08 +0200
commitbb89d065dbe47554c0cb929d244e0d38cad52e65 (patch)
tree429feea4650430532ad23210de981ced039bc289 /erts/emulator
parent90aacace4bdb1c883c3829bc66c1c616a81943d9 (diff)
downloadotp-bb89d065dbe47554c0cb929d244e0d38cad52e65.tar.gz
otp-bb89d065dbe47554c0cb929d244e0d38cad52e65.tar.bz2
otp-bb89d065dbe47554c0cb929d244e0d38cad52e65.zip
beam_emu: Slightly optimize the bxor/2 operator
bxor is used in the rand module, so even small optimizations could be worthwile. Suggested by Raimo Niskanen.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/beam_emu.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index 9a91fdce08..6010c17c17 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -3044,10 +3044,12 @@ do { \
GetArg2(2, Op1, Op2);
if (is_both_small(Op1, Op2)) {
/*
- * We could extract the tag from one argument, but a tag extraction
- * could mean a shift. Therefore, play it safe here.
+ * TAG ^ TAG == 0.
+ *
+ * Therefore, we perform the XOR operation on the tagged values,
+ * and OR in the tag bits.
*/
- Eterm result = make_small(signed_val(Op1) ^ signed_val(Op2));
+ Eterm result = (Op1 ^ Op2) | make_small(0);
StoreBifResult(4, result);
}
DO_OUTLINED_ARITH_2(bxor, Op1, Op2);