]> granicus.if.org Git - php/commitdiff
Combine conditions
authorDmitry Stogov <dmitry@zend.com>
Thu, 11 Feb 2016 20:11:19 +0000 (23:11 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 11 Feb 2016 20:11:19 +0000 (23:11 +0300)
Zend/zend_compile.c
ext/opcache/Optimizer/block_pass.c
ext/opcache/Optimizer/zend_dfg.c
ext/opcache/Optimizer/zend_dump.c
ext/opcache/Optimizer/zend_ssa.c

index bc871ed454eb44c002ab80c6f8e3995e869d212a..01135ec9cd8a744df5e99991fda45a4c9c17cf4a 100644 (file)
@@ -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;
index 665515de018ae27283c6df60f5de446e3937970c..b582ef5484b1930350ebd56f54e5744ddf4d6b43 100644 (file)
@@ -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 (opline<end) {
-                       if (opline->op1_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));
                        }
 
index 704b84eaac6d3340d630796e3e6ca3d1e5a260fe..e72afd170177f60e90443d0a2ec414493bd0d221 100644 (file)
@@ -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));
                                        }
index b0607c61b42d52dd26aff9d4bfbe462e1cf38430..155850eb5f5f860dbc5f7ed6c4fa1b08cd2d2b45 100644 (file)
@@ -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) {
index 08203ec0c7ee01973952d989b3611df94f56aafd..0da793918c5511e973efeff026d05811074e9d18 100644 (file)
@@ -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++;