diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-22 07:53:37 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-22 07:53:37 +0000 |
commit | df93a07990373ff1595ebc93961c0e10301b2f5e (patch) | |
tree | fc323ff2449a0139c6f97472dba30e3870cc4503 /parse.y | |
parent | 28f859a9654585e606f445985d5c618308a5f61c (diff) | |
download | ruby-df93a07990373ff1595ebc93961c0e10301b2f5e.tar.gz |
compile.c: move logop DCE
* compile.c (iseq_peephole_optimize): remove unreachable code
chunk after jump/leave.
* parse.y: move dead code elimination of logical operation to
compile.c. not to warn logical operation of literal constants.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 29 |
1 files changed, 1 insertions, 28 deletions
@@ -9747,15 +9747,6 @@ new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right) { if (!cc) return right; cc = cond0(parser, cc); - switch (nd_type(cc)) { - case NODE_NIL: - case NODE_FALSE: - return right; - case NODE_TRUE: - case NODE_LIT: - case NODE_STR: - return left; - } return NEW_IF(cc, left, right); } @@ -9763,11 +9754,7 @@ static NODE* logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right) { value_expr(left); - if (!left) { - if (!in_defined && type == NODE_AND) return 0; - /* make NODE_OR not to be "void value expression" */ - } - else if ((enum node_type)nd_type(left) == type) { + if (left && (enum node_type)nd_type(left) == type) { NODE *node = left, *second; while ((second = node->nd_2nd) != 0 && (enum node_type)nd_type(second) == type) { node = second; @@ -9775,20 +9762,6 @@ logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *r node->nd_2nd = NEW_NODE(type, second, right, 0); return left; } - else if (!in_defined) { - switch (nd_type(left)) { - case NODE_NIL: - case NODE_FALSE: - if (type == NODE_AND) return left; - break; - case NODE_TRUE: - case NODE_LIT: - case NODE_STR: - if (type != NODE_AND) return left; - nd_set_type(left, NODE_TRUE); - break; - } - } return NEW_NODE(type, left, right, 0); } |