From: Dmitry Stogov Date: Thu, 11 Feb 2016 20:11:19 +0000 (+0300) Subject: Combine conditions X-Git-Tag: php-7.1.0alpha1~617^2~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c2d55962e2265cabfdf74d4072478f55d3cf6ab;p=php Combine conditions --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index bc871ed454..01135ec9cd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3834,7 +3834,7 @@ static int zend_handle_loops_and_finally_ex(zend_long depth) /* {{{ */ } else { zend_op *opline; - ZEND_ASSERT(loop_var->var_type == IS_VAR || loop_var->var_type == IS_TMP_VAR); + ZEND_ASSERT(loop_var->var_type & (IS_VAR|IS_TMP_VAR)); opline = get_next_op(CG(active_op_array)); opline->opcode = loop_var->opcode; opline->op1_type = loop_var->var_type; @@ -4363,7 +4363,7 @@ void zend_compile_switch(zend_ast *ast) /* {{{ */ zend_end_loop(get_next_op_number(CG(active_op_array)), &expr_node); - if (expr_node.op_type == IS_VAR || expr_node.op_type == IS_TMP_VAR) { + if (expr_node.op_type & (IS_VAR|IS_TMP_VAR)) { /* don't use emit_op() to prevent automatic live-range construction */ opline = get_next_op(CG(active_op_array)); opline->opcode = ZEND_FREE; diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 665515de01..b582ef5484 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -749,7 +749,7 @@ optimize_const_unary_op: } /* get variable source */ - if (opline->result_type == IS_VAR || opline->result_type == IS_TMP_VAR) { + if (opline->result_type & (IS_VAR|IS_TMP_VAR)) { SET_VAR_SOURCE(opline); } opline++; @@ -1504,7 +1504,7 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use } while (oplineop1_type == IS_VAR || opline->op1_type == IS_TMP_VAR) { + if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) { var_num = VAR_NUM(opline->op1.var); if (!zend_bitset_in(defined_here, var_num)) { zend_bitset_incl(used_ext, var_num); @@ -1670,7 +1670,7 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use zend_bitset_incl(usage, VAR_NUM(opline->op2.var)); } - if (opline->op1_type == IS_VAR || opline->op1_type == IS_TMP_VAR) { + if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) { zend_bitset_incl(usage, VAR_NUM(opline->op1.var)); } diff --git a/ext/opcache/Optimizer/zend_dfg.c b/ext/opcache/Optimizer/zend_dfg.c index 704b84eaac..e72afd1701 100644 --- a/ext/opcache/Optimizer/zend_dfg.c +++ b/ext/opcache/Optimizer/zend_dfg.c @@ -135,8 +135,7 @@ op1_use: DFG_SET(use, set_size, j, EX_VAR_TO_NUM(opline->op1.var)); } } - } else if (opline->op1_type == IS_VAR || - opline->op1_type == IS_TMP_VAR) { + } else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) { if (!DFG_ISSET(def, set_size, j, EX_VAR_TO_NUM(opline->op1.var))) { DFG_SET(use, set_size, j, EX_VAR_TO_NUM(opline->op1.var)); } @@ -171,8 +170,7 @@ op2_use: } break; } - } else if (opline->op2_type == IS_VAR || - opline->op2_type == IS_TMP_VAR) { + } else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) { if (opline->opcode == ZEND_FE_FETCH_R || opline->opcode == ZEND_FE_FETCH_RW) { if (!DFG_ISSET(use, set_size, j, EX_VAR_TO_NUM(opline->op2.var))) { DFG_SET(def, set_size, j, EX_VAR_TO_NUM(opline->op2.var)); @@ -189,8 +187,7 @@ op2_use: DFG_SET(def, set_size, j, EX_VAR_TO_NUM(opline->result.var)); } DFG_SET(gen, set_size, j, EX_VAR_TO_NUM(opline->result.var)); - } else if (opline->result_type == IS_VAR || - opline->result_type == IS_TMP_VAR) { + } else if (opline->result_type & (IS_VAR|IS_TMP_VAR)) { if (!DFG_ISSET(use, set_size, j, EX_VAR_TO_NUM(opline->result.var))) { DFG_SET(def, set_size, j, EX_VAR_TO_NUM(opline->result.var)); } diff --git a/ext/opcache/Optimizer/zend_dump.c b/ext/opcache/Optimizer/zend_dump.c index b0607c61b4..155850eb5f 100644 --- a/ext/opcache/Optimizer/zend_dump.c +++ b/ext/opcache/Optimizer/zend_dump.c @@ -393,9 +393,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * fprintf(stderr, "%*c", 8-len, ' '); if (!ssa || !ssa->ops || ssa->ops[opline - op_array->opcodes].result_use < 0) { - if (opline->result_type == IS_CV || - opline->result_type == IS_VAR || - opline->result_type == IS_TMP_VAR) { + if (opline->result_type & (IS_CV|IS_VAR|IS_TMP_VAR)) { if (ssa && ssa->ops) { int ssa_var_num = ssa->ops[opline - op_array->opcodes].result_def; ZEND_ASSERT(ssa_var_num >= 0); @@ -567,9 +565,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->op1_type == IS_CONST) { zend_dump_const(CRT_CONSTANT_EX(op_array, opline->op1, (dump_flags & ZEND_DUMP_RT_CONSTANTS))); - } else if (opline->op1_type == IS_CV || - opline->op1_type == IS_VAR || - opline->op1_type == IS_TMP_VAR) { + } else if (opline->op1_type & (IS_CV|IS_VAR|IS_TMP_VAR)) { if (ssa && ssa->ops) { int ssa_var_num = ssa->ops[opline - op_array->opcodes].op1_use; if (ssa_var_num >= 0) { @@ -605,9 +601,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->op2_type == IS_CONST) { zend_dump_const(CRT_CONSTANT_EX(op_array, opline->op2, (dump_flags & ZEND_DUMP_RT_CONSTANTS))); - } else if (opline->op2_type == IS_CV || - opline->op2_type == IS_VAR || - opline->op2_type == IS_TMP_VAR) { + } else if (opline->op2_type & (IS_CV|IS_VAR|IS_TMP_VAR)) { if (ssa && ssa->ops) { int ssa_var_num = ssa->ops[opline - op_array->opcodes].op2_use; if (ssa_var_num >= 0) { @@ -653,9 +647,7 @@ static void zend_dump_op(const zend_op_array *op_array, const zend_basic_block * if (opline->result_type == IS_CONST) { zend_dump_const(CRT_CONSTANT_EX(op_array, opline->result, (dump_flags & ZEND_DUMP_RT_CONSTANTS))); } else if (ssa && ssa->ops && ssa->ops[opline - op_array->opcodes].result_use >= 0) { - if (opline->result_type == IS_CV || - opline->result_type == IS_VAR || - opline->result_type == IS_TMP_VAR) { + if (opline->result_type & (IS_CV|IS_VAR|IS_TMP_VAR)) { if (ssa && ssa->ops) { int ssa_var_num = ssa->ops[opline - op_array->opcodes].result_use; if (ssa_var_num >= 0) { diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index 08203ec0c7..0da793918c 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -488,16 +488,14 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags, if (next->op1_type == IS_CV) { ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)]; //USE_SSA_VAR(next->op1.var); - } else if (next->op1_type == IS_VAR || - next->op1_type == IS_TMP_VAR) { + } else if (next->op1_type & (IS_VAR|IS_TMP_VAR)) { ssa_ops[k + 1].op1_use = var[EX_VAR_TO_NUM(next->op1.var)]; //USE_SSA_VAR(op_array->last_var + next->op1.var); } if (next->op2_type == IS_CV) { ssa_ops[k + 1].op2_use = var[EX_VAR_TO_NUM(next->op2.var)]; //USE_SSA_VAR(next->op2.var); - } else if (next->op2_type == IS_VAR || - next->op2_type == IS_TMP_VAR) { + } else if (next->op2_type & (IS_VAR|IS_TMP_VAR)) { ssa_ops[k + 1].op2_use = var[EX_VAR_TO_NUM(next->op2.var)]; //USE_SSA_VAR(op_array->last_var + next->op2.var); } @@ -674,8 +672,7 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags, var[EX_VAR_TO_NUM(opline->result.var)] = ssa_vars_count; ssa_vars_count++; //NEW_SSA_VAR(opline->result.var) - } else if (opline->result_type == IS_VAR || - opline->result_type == IS_TMP_VAR) { + } else if (opline->result_type & (IS_VAR|IS_TMP_VAR)) { ssa_ops[k].result_def = ssa_vars_count; var[EX_VAR_TO_NUM(opline->result.var)] = ssa_vars_count; ssa_vars_count++;