aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-04-23 15:34:07 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-04-23 15:34:07 +0200
commit06a912c068f62e1e04ebb2aa2002d611b8cc31e3 (patch)
tree5059ab538a572b73282ee7d20636023b051cf8f2
parentd1321eaf9bd1e417561e3d70fd85749fe589143b (diff)
downloadotp-06a912c068f62e1e04ebb2aa2002d611b8cc31e3.tar.gz
otp-06a912c068f62e1e04ebb2aa2002d611b8cc31e3.tar.bz2
otp-06a912c068f62e1e04ebb2aa2002d611b8cc31e3.zip
erts: Fix loader increment from minus instruction
A type error caused the optimization to never kick in.
-rw-r--r--erts/emulator/beam/beam_load.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 8d7beb4eb4..282aa71109 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -3172,7 +3172,11 @@ gen_increment_from_minus(LoaderState* stp, GenOpArg Reg, GenOpArg Integer,
static int
negation_is_small(LoaderState* stp, GenOpArg Int)
{
- return Int.type == TAG_i && IS_SSMALL(-Int.val);
+ /* Check for the rare case of overflow in BeamInstr (UWord) -> Sint
+ * Cast to the correct type before using IS_SSMALL (Sint) */
+ return Int.type == TAG_i &&
+ !(Int.val & ~((((BeamInstr)1) << ((sizeof(Sint)*8)-1))-1)) &&
+ IS_SSMALL(-((Sint)Int.val));
}