Permalink
Browse files

Don't generate code for NODE_NEGATE if the result isn't used

  • Loading branch information...
bouk committed Dec 2, 2016
1 parent 5930a6e commit d56a19cbf526190de036130fe3a5bf14a0705ee2
Showing with 14 additions and 0 deletions.
  1. +4 −0 mrbgems/mruby-compiler/core/codegen.c
  2. +10 −0 test/t/codegen.rb
@@ -2223,6 +2223,10 @@ codegen(codegen_scope *s, node *tree, int val)
{
nt = (intptr_t)tree->car;
tree = tree->cdr;
if (!val) {
codegen(s, tree, NOVAL);
break;
}
switch (nt) {
case NODE_FLOAT:
{
View
@@ -63,3 +63,13 @@ def args_to_ary(*args)
assert_equal [1], a
end
assert('negate literal register alignment') do
a = *case
when 0
-0.0
2
end
assert_equal [2], a
end

0 comments on commit d56a19c

Please sign in to comment.