aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-11-11 19:01:22 +0100
committerBjörn Gustavsson <[email protected]>2011-01-17 15:23:42 +0100
commit4d05097ec97cc18c795ffee83d1d08d396e16814 (patch)
tree077c96c7c1dd69dc43de00425dbd77fd87be081a /erts/emulator
parent824a481d5f38c748cd6efcb83cba0b8d26b88768 (diff)
downloadotp-4d05097ec97cc18c795ffee83d1d08d396e16814.tar.gz
otp-4d05097ec97cc18c795ffee83d1d08d396e16814.tar.bz2
otp-4d05097ec97cc18c795ffee83d1d08d396e16814.zip
Simplify a select_val instruction that selects only one value
The compiler does not generate select_val instructions that only selects one value, but the loader may previously have created such an instruction when it splitted a select_val instruction that selected on bignums.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/beam_load.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index a476e439ca..73f057929e 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -3096,6 +3096,29 @@ gen_jump_tab(LoaderState* stp, GenOpArg S, GenOpArg Fail, GenOpArg Size, GenOpAr
ASSERT(Size.val >= 2 && Size.val % 2 == 0);
/*
+ * If there is only one choice, don't generate a jump table.
+ */
+ if (Size.val == 2) {
+ GenOp* jump;
+
+ NEW_GENOP(stp, op);
+ op->arity = 3;
+ op->op = genop_is_ne_exact_3;
+ op->a[0] = Rest[1];
+ op->a[1] = S;
+ op->a[2] = Rest[0];
+
+ NEW_GENOP(stp, jump);
+ jump->next = NULL;
+ jump->arity = 1;
+ jump->op = genop_jump_1;
+ jump->a[0] = Fail;
+
+ op->next = jump;
+ return op;
+ }
+
+ /*
* Calculate the minimum and maximum values and size of jump table.
*/