Skip to content
Permalink
Browse files
Don't generate code for NODE_NEGATE if the result isn't used
  • Loading branch information
bouk committed Dec 7, 2016
1 parent 5930a6e commit d56a19cbf526190de036130fe3a5bf14a0705ee2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
@@ -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:
{
@@ -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.