Lines Matching refs:ssa
42 int zend_dfa_analyze_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, zend_ssa *ssa) in zend_dfa_analyze_op_array() argument
52 memset(ssa, 0, sizeof(zend_ssa)); in zend_dfa_analyze_op_array()
54 if (zend_build_cfg(&ctx->arena, op_array, ZEND_CFG_NO_ENTRY_PREDECESSORS, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
58 if ((ssa->cfg.flags & ZEND_FUNC_INDIRECT_VAR_ACCESS)) { in zend_dfa_analyze_op_array()
63 if (zend_cfg_build_predecessors(&ctx->arena, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
68 zend_dump_op_array(op_array, ZEND_DUMP_CFG, "dfa cfg", &ssa->cfg); in zend_dfa_analyze_op_array()
72 if (zend_cfg_compute_dominators_tree(op_array, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
77 if (zend_cfg_identify_loops(op_array, &ssa->cfg) != SUCCESS) { in zend_dfa_analyze_op_array()
82 zend_dump_dominators(op_array, &ssa->cfg); in zend_dfa_analyze_op_array()
92 if (zend_build_ssa(&ctx->arena, ctx->script, op_array, build_flags, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
97 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "dfa ssa", ssa); in zend_dfa_analyze_op_array()
101 if (zend_ssa_compute_use_def_chains(&ctx->arena, op_array, ssa) != SUCCESS){ in zend_dfa_analyze_op_array()
105 if (zend_ssa_find_false_dependencies(op_array, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
109 if (zend_ssa_find_sccs(op_array, ssa) != SUCCESS){ in zend_dfa_analyze_op_array()
113 …if (zend_ssa_inference(&ctx->arena, op_array, ctx->script, ssa, ctx->optimization_level) != SUCCES… in zend_dfa_analyze_op_array()
117 if (zend_ssa_escape_analysis(ctx->script, op_array, ssa) != SUCCESS) { in zend_dfa_analyze_op_array()
122 zend_dump_ssa_variables(op_array, ssa, 0); in zend_dfa_analyze_op_array()
128 static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_optimizer_ctx *ctx) in zend_ssa_remove_nops() argument
130 zend_basic_block *blocks = ssa->cfg.blocks; in zend_ssa_remove_nops()
131 zend_basic_block *blocks_end = blocks + ssa->cfg.blocks_count; in zend_ssa_remove_nops()
178 ssa->ops[target] = ssa->ops[i]; in zend_ssa_remove_nops()
179 ssa->cfg.map[target] = b - blocks; in zend_ssa_remove_nops()
215 for (j = 0; j < ssa->vars_count; j++) { in zend_ssa_remove_nops()
216 if (ssa->vars[j].definition >= 0) { in zend_ssa_remove_nops()
217 ssa->vars[j].definition -= shiftlist[ssa->vars[j].definition]; in zend_ssa_remove_nops()
219 if (ssa->vars[j].use_chain >= 0) { in zend_ssa_remove_nops()
220 ssa->vars[j].use_chain -= shiftlist[ssa->vars[j].use_chain]; in zend_ssa_remove_nops()
224 if (ssa->ops[i].op1_use_chain >= 0) { in zend_ssa_remove_nops()
225 ssa->ops[i].op1_use_chain -= shiftlist[ssa->ops[i].op1_use_chain]; in zend_ssa_remove_nops()
227 if (ssa->ops[i].op2_use_chain >= 0) { in zend_ssa_remove_nops()
228 ssa->ops[i].op2_use_chain -= shiftlist[ssa->ops[i].op2_use_chain]; in zend_ssa_remove_nops()
230 if (ssa->ops[i].res_use_chain >= 0) { in zend_ssa_remove_nops()
231 ssa->ops[i].res_use_chain -= shiftlist[ssa->ops[i].res_use_chain]; in zend_ssa_remove_nops()
295 zend_op_array *op_array, zend_ssa *ssa, zend_ssa_op *ssa_op) { in can_elide_return_type_check() argument
297 zend_ssa_var_info *use_info = &ssa->var_info[ssa_op->op1_use]; in can_elide_return_type_check()
298 zend_ssa_var_info *def_info = &ssa->var_info[ssa_op->op1_def]; in can_elide_return_type_check()
326 zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) { in opline_supports_assign_contraction() argument
336 uint32_t type = ssa->var_info[src_var].type; in opline_supports_assign_contraction()
365 && zend_may_throw(opline, &ssa->ops[ssa->vars[src_var].definition], op_array, ssa)) { in opline_supports_assign_contraction()
372 static bool variable_defined_or_used_in_range(zend_ssa *ssa, int var, int start, int end) in variable_defined_or_used_in_range() argument
375 const zend_ssa_op *ssa_op = &ssa->ops[start]; in variable_defined_or_used_in_range()
376 if ((ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].var == var) || in variable_defined_or_used_in_range()
377 (ssa_op->op2_def >= 0 && ssa->vars[ssa_op->op2_def].var == var) || in variable_defined_or_used_in_range()
378 (ssa_op->result_def >= 0 && ssa->vars[ssa_op->result_def].var == var) || in variable_defined_or_used_in_range()
379 (ssa_op->op1_use >= 0 && ssa->vars[ssa_op->op1_use].var == var) || in variable_defined_or_used_in_range()
380 (ssa_op->op2_use >= 0 && ssa->vars[ssa_op->op2_use].var == var) || in variable_defined_or_used_in_range()
381 (ssa_op->result_use >= 0 && ssa->vars[ssa_op->result_use].var == var) in variable_defined_or_used_in_range()
390 int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) in zend_dfa_optimize_calls() argument
463 zend_ssa_op *ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
468 zend_ssa_var *var = ssa->vars + var_num; in zend_dfa_optimize_calls()
471 zend_ssa_unlink_use_chain(ssa, op_num, ssa_op->op1_use); in zend_dfa_optimize_calls()
475 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
499 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_calls()
502 int use = ssa->vars[var].use_chain; in zend_dfa_optimize_calls()
507 if (ssa->vars[var].phi_use_chain == NULL in zend_dfa_optimize_calls()
508 && ssa->ops[use].op1_use == var in zend_dfa_optimize_calls()
509 && ssa->ops[use].op1_use_chain == -1 in zend_dfa_optimize_calls()
526 static zend_always_inline void take_successor_0(zend_ssa *ssa, int block_num, zend_basic_block *blo… in take_successor_0() argument
530 zend_ssa_remove_predecessor(ssa, block_num, block->successors[1]); in take_successor_0()
536 static zend_always_inline void take_successor_1(zend_ssa *ssa, int block_num, zend_basic_block *blo… in take_successor_1() argument
540 zend_ssa_remove_predecessor(ssa, block_num, block->successors[0]); in take_successor_1()
547 static zend_always_inline void take_successor_ex(zend_ssa *ssa, int block_num, zend_basic_block *bl… in take_successor_ex() argument
553 zend_ssa_remove_predecessor(ssa, block_num, block->successors[i]); in take_successor_ex()
573 static void replace_predecessor(zend_ssa *ssa, int block_id, int old_pred, int new_pred) { in replace_predecessor() argument
574 zend_basic_block *block = &ssa->cfg.blocks[block_id]; in replace_predecessor()
575 int *predecessors = &ssa->cfg.predecessors[block->predecessor_offset]; in replace_predecessor()
604 for (phi = ssa->blocks[block_id].phis; phi; phi = phi->next) { in replace_predecessor()
608 ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0); in replace_predecessor()
609 zend_ssa_remove_phi(ssa, phi); in replace_predecessor()
624 static void zend_ssa_replace_control_link(zend_op_array *op_array, zend_ssa *ssa, int from, int to,… in zend_ssa_replace_control_link() argument
626 zend_basic_block *src = &ssa->cfg.blocks[from]; in zend_ssa_replace_control_link()
627 zend_basic_block *old = &ssa->cfg.blocks[to]; in zend_ssa_replace_control_link()
628 zend_basic_block *dst = &ssa->cfg.blocks[new_to]; in zend_ssa_replace_control_link()
697 replace_predecessor(ssa, new_to, to, from); in zend_ssa_replace_control_link()
700 static void zend_ssa_unlink_block(zend_op_array *op_array, zend_ssa *ssa, zend_basic_block *block, … in zend_ssa_unlink_block() argument
702 if (block->predecessors_count == 1 && ssa->blocks[block_num].phis == NULL) { in zend_ssa_unlink_block()
707 predecessors = &ssa->cfg.predecessors[block->predecessor_offset]; in zend_ssa_unlink_block()
709 zend_basic_block *pred_block = &ssa->cfg.blocks[predecessors[0]]; in zend_ssa_unlink_block()
720 zend_ssa_replace_control_link(op_array, ssa, predecessors[i], block_num, block->successors[0]); in zend_ssa_unlink_block()
722 zend_ssa_remove_block(op_array, ssa, block_num); in zend_ssa_unlink_block()
725 int ssa_var = ssa->ops[fe_fetch_block->start + fe_fetch_block->len - 1].op2_def; in zend_ssa_unlink_block()
727 zend_ssa_remove_uses_of_var(ssa, ssa_var); in zend_ssa_unlink_block()
733 static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa) in zend_dfa_optimize_jmps() argument
738 for (block_num = 1; block_num < ssa->cfg.blocks_count; block_num++) { in zend_dfa_optimize_jmps()
739 zend_basic_block *block = &ssa->cfg.blocks[block_num]; in zend_dfa_optimize_jmps()
746 zend_ssa_unlink_block(op_array, ssa, block, block_num); in zend_dfa_optimize_jmps()
751 while (block_num < ssa->cfg.blocks_count in zend_dfa_optimize_jmps()
752 && !(ssa->cfg.blocks[block_num].flags & ZEND_BB_REACHABLE)) { in zend_dfa_optimize_jmps()
755 while (block_num < ssa->cfg.blocks_count) { in zend_dfa_optimize_jmps()
757 zend_basic_block *block = &ssa->cfg.blocks[block_num]; in zend_dfa_optimize_jmps()
763 while (next_block_num < ssa->cfg.blocks_count in zend_dfa_optimize_jmps()
764 && !(ssa->cfg.blocks[next_block_num].flags & ZEND_BB_REACHABLE)) { in zend_dfa_optimize_jmps()
765 if (ssa->cfg.blocks[next_block_num].flags & ZEND_BB_UNREACHABLE_FREE) { in zend_dfa_optimize_jmps()
774 ssa_op = ssa->ops + op_num; in zend_dfa_optimize_jmps()
791 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
796 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
801 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
806 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
822 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
827 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
832 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
837 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
852 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
856 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
864 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
870 zend_ssa_remove_instr(ssa, opline, ssa_op); in zend_dfa_optimize_jmps()
879 zend_ssa_unlink_use_chain(ssa, op_num, ssa_op->op1_use); in zend_dfa_optimize_jmps()
891 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
892 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
895 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
900 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
905 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
906 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
909 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
914 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
919 if (ssa->vars[ssa_op->result_def].use_chain < 0 in zend_dfa_optimize_jmps()
920 && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) { in zend_dfa_optimize_jmps()
923 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
929 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
930 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
937 zend_ssa_var *var = &ssa->vars[ssa_op->result_def]; in zend_dfa_optimize_jmps()
941 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
944 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
949 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
951 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
959 zend_ssa_var *var = &ssa->vars[ssa_op->result_def]; in zend_dfa_optimize_jmps()
965 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
967 take_successor_0(ssa, block_num, block); in zend_dfa_optimize_jmps()
970 zend_ssa_remove_result_def(ssa, ssa_op); in zend_dfa_optimize_jmps()
973 take_successor_1(ssa, block_num, block); in zend_dfa_optimize_jmps()
994 take_successor_ex(ssa, block_num, block, block->successors[block->successors_count - 1]); in zend_dfa_optimize_jmps()
1013 take_successor_ex(ssa, block_num, block, ssa->cfg.map[target]); in zend_dfa_optimize_jmps()
1023 zend_ssa_unlink_block(op_array, ssa, block, block_num); in zend_dfa_optimize_jmps()
1028 && !(ssa->cfg.blocks[block_num].flags & ZEND_BB_REACHABLE)); in zend_dfa_optimize_jmps()
1046 static int zend_dfa_try_to_replace_result(zend_op_array *op_array, zend_ssa *ssa, int def, int cv_v… in zend_dfa_try_to_replace_result() argument
1048 int result_var = ssa->ops[def].result_def; in zend_dfa_try_to_replace_result()
1049 int cv = EX_NUM_TO_VAR(ssa->vars[cv_var].var); in zend_dfa_try_to_replace_result()
1052 && !(ssa->var_info[cv_var].type & MAY_BE_REF) in zend_dfa_try_to_replace_result()
1053 && ssa->vars[cv_var].alias == NO_ALIAS in zend_dfa_try_to_replace_result()
1054 && ssa->vars[result_var].phi_use_chain == NULL in zend_dfa_try_to_replace_result()
1055 && ssa->vars[result_var].sym_use_chain == NULL) { in zend_dfa_try_to_replace_result()
1056 int use = ssa->vars[result_var].use_chain; in zend_dfa_try_to_replace_result()
1059 && zend_ssa_next_use(ssa->ops, result_var, use) < 0 in zend_dfa_try_to_replace_result()
1080 ssa->vars[result_var].definition = -1; in zend_dfa_try_to_replace_result()
1081 ssa->vars[result_var].use_chain = -1; in zend_dfa_try_to_replace_result()
1082 ssa->ops[def].result_def = -1; in zend_dfa_try_to_replace_result()
1087 if (ssa->ops[use].op1_use == result_var) { in zend_dfa_try_to_replace_result()
1088 ssa->ops[use].op1_use = cv_var; in zend_dfa_try_to_replace_result()
1089 ssa->ops[use].op1_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1090 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1094 } else if (ssa->ops[use].op2_use == result_var) { in zend_dfa_try_to_replace_result()
1095 ssa->ops[use].op2_use = cv_var; in zend_dfa_try_to_replace_result()
1096 ssa->ops[use].op2_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1097 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1101 } else if (ssa->ops[use].result_use == result_var) { in zend_dfa_try_to_replace_result()
1102 ssa->ops[use].result_use = cv_var; in zend_dfa_try_to_replace_result()
1103 ssa->ops[use].res_use_chain = ssa->vars[cv_var].use_chain; in zend_dfa_try_to_replace_result()
1104 ssa->vars[cv_var].use_chain = use; in zend_dfa_try_to_replace_result()
1118 void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, zend_ssa *ssa, ze… in zend_dfa_optimize_op_array() argument
1121 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "before dfa pass", ssa); in zend_dfa_optimize_op_array()
1124 if (ssa->var_info) { in zend_dfa_optimize_op_array()
1133 ssa_verify_integrity(op_array, ssa, "before dfa"); in zend_dfa_optimize_op_array()
1137 if (sccp_optimize_op_array(ctx, op_array, ssa, call_map)) { in zend_dfa_optimize_op_array()
1141 if (zend_dfa_optimize_jmps(op_array, ssa)) { in zend_dfa_optimize_op_array()
1146 ssa_verify_integrity(op_array, ssa, "after sccp"); in zend_dfa_optimize_op_array()
1149 if (zend_dfa_optimize_calls(op_array, ssa)) { in zend_dfa_optimize_op_array()
1154 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after sccp pass", ssa); in zend_dfa_optimize_op_array()
1157 ssa_verify_integrity(op_array, ssa, "after calls"); in zend_dfa_optimize_op_array()
1162 if (dce_optimize_op_array(op_array, ssa, 0)) { in zend_dfa_optimize_op_array()
1165 if (zend_dfa_optimize_jmps(op_array, ssa)) { in zend_dfa_optimize_op_array()
1169 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after dce pass", ssa); in zend_dfa_optimize_op_array()
1172 ssa_verify_integrity(op_array, ssa, "after dce"); in zend_dfa_optimize_op_array()
1176 for (v = op_array->last_var; v < ssa->vars_count; v++) { in zend_dfa_optimize_op_array()
1178 op_1 = ssa->vars[v].definition; in zend_dfa_optimize_op_array()
1185 ssa_op = &ssa->ops[op_1]; in zend_dfa_optimize_op_array()
1188 if (ssa->var_info[v].use_as_double) { in zend_dfa_optimize_op_array()
1191 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1253 ssa->ops[op_1].op1_use = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1254 ssa->ops[op_1].op1_use_chain = ssa->ops[op_1].op2_use_chain; in zend_dfa_optimize_op_array()
1255 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1256 ssa->ops[op_1].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1294 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1295 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1296 && ssa->ops[op_1].op1_use_chain == -1 in zend_dfa_optimize_op_array()
1297 && ssa->vars[v].use_chain >= 0 in zend_dfa_optimize_op_array()
1298 && can_elide_return_type_check(op_array, ssa, &ssa->ops[op_1])) { in zend_dfa_optimize_op_array()
1302 int orig_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1303 if (zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1305 int ret = ssa->vars[v].use_chain; in zend_dfa_optimize_op_array()
1307 ssa->ops[ret].op1_use = orig_var; in zend_dfa_optimize_op_array()
1308 ssa->ops[ret].op1_use_chain = ssa->vars[orig_var].use_chain; in zend_dfa_optimize_op_array()
1309 ssa->vars[orig_var].use_chain = ret; in zend_dfa_optimize_op_array()
1311 ssa->vars[v].definition = -1; in zend_dfa_optimize_op_array()
1312 ssa->vars[v].use_chain = -1; in zend_dfa_optimize_op_array()
1314 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1315 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1324 && ssa->ops[op_1].result_def == v in zend_dfa_optimize_op_array()
1326 …&& !(ssa->var_info[v].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) in zend_dfa_optimize_op_array()
1329 int src_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1332 && !(ssa->var_info[src_var].type & MAY_BE_REF) in zend_dfa_optimize_op_array()
1333 && ssa->vars[src_var].definition >= 0 in zend_dfa_optimize_op_array()
1334 && ssa->ops[ssa->vars[src_var].definition].result_def == src_var in zend_dfa_optimize_op_array()
1335 && ssa->ops[ssa->vars[src_var].definition].result_use < 0 in zend_dfa_optimize_op_array()
1336 && ssa->vars[src_var].use_chain == op_1 in zend_dfa_optimize_op_array()
1337 && ssa->ops[op_1].op1_use_chain < 0 in zend_dfa_optimize_op_array()
1338 && !ssa->vars[src_var].phi_use_chain in zend_dfa_optimize_op_array()
1339 && !ssa->vars[src_var].sym_use_chain in zend_dfa_optimize_op_array()
1341 op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition], in zend_dfa_optimize_op_array()
1343 && !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->result.var), in zend_dfa_optimize_op_array()
1344 ssa->vars[src_var].definition+1, op_1) in zend_dfa_optimize_op_array()
1347 int orig_var = ssa->ops[op_1].result_use; in zend_dfa_optimize_op_array()
1348 int op_2 = ssa->vars[src_var].definition; in zend_dfa_optimize_op_array()
1353 if (orig_var < 0 || zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1355 ssa->vars[v].definition = op_2; in zend_dfa_optimize_op_array()
1356 ssa->ops[op_2].result_def = v; in zend_dfa_optimize_op_array()
1358 ssa->vars[src_var].definition = -1; in zend_dfa_optimize_op_array()
1359 ssa->vars[src_var].use_chain = -1; in zend_dfa_optimize_op_array()
1361 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1362 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1363 ssa->ops[op_1].op1_use_chain = -1; in zend_dfa_optimize_op_array()
1364 ssa->ops[op_1].result_use = -1; in zend_dfa_optimize_op_array()
1365 ssa->ops[op_1].result_def = -1; in zend_dfa_optimize_op_array()
1366 ssa->ops[op_1].res_use_chain = -1; in zend_dfa_optimize_op_array()
1381 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1382 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1388 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1389 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1397 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1398 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1404 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1405 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1413 && ssa->ops[op_2].op2_use >= 0 in zend_dfa_optimize_op_array()
1414 …&& !(ssa->var_info[ssa->ops[op_2].op2_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1422 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1423 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1424 ssa->ops[op_2].op1_use = ssa->ops[op_2].op2_use; in zend_dfa_optimize_op_array()
1425 ssa->ops[op_2].op1_use_chain = ssa->ops[op_2].op2_use_chain; in zend_dfa_optimize_op_array()
1426 ssa->ops[op_2].op2_use = -1; in zend_dfa_optimize_op_array()
1427 ssa->ops[op_2].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1433 if (ssa->vars[v].var >= op_array->last_var) { in zend_dfa_optimize_op_array()
1438 if (ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1444 zend_dfa_try_to_replace_result(op_array, ssa, op_1, v); in zend_dfa_optimize_op_array()
1446 int result_var = ssa->ops[op_1].result_def; in zend_dfa_optimize_op_array()
1449 …&& (ssa->var_info[result_var].type & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_D… in zend_dfa_optimize_op_array()
1450 int use = ssa->vars[result_var].use_chain; in zend_dfa_optimize_op_array()
1453 && ssa->ops[use].op1_use == result_var in zend_dfa_optimize_op_array()
1454 && zend_dfa_try_to_replace_result(op_array, ssa, op_1, v)) { in zend_dfa_optimize_op_array()
1460 int result_var = ssa->ops[op_1].result_def; in zend_dfa_optimize_op_array()
1463 …&& (ssa->var_info[result_var].type & ((MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_D… in zend_dfa_optimize_op_array()
1464 int use = ssa->vars[result_var].use_chain; in zend_dfa_optimize_op_array()
1467 && ssa->ops[use].op2_use == result_var in zend_dfa_optimize_op_array()
1468 && zend_dfa_try_to_replace_result(op_array, ssa, op_1, v)) { in zend_dfa_optimize_op_array()
1477 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1480 int orig_var = ssa->ops[op_1].op1_use; in zend_dfa_optimize_op_array()
1483 …&& !(ssa->var_info[orig_var].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_… in zend_dfa_optimize_op_array()
1485 int src_var = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1489 && !(ssa->var_info[src_var].type & MAY_BE_REF) in zend_dfa_optimize_op_array()
1490 && ssa->vars[src_var].definition >= 0 in zend_dfa_optimize_op_array()
1491 && ssa->ops[ssa->vars[src_var].definition].result_def == src_var in zend_dfa_optimize_op_array()
1492 && ssa->ops[ssa->vars[src_var].definition].result_use < 0 in zend_dfa_optimize_op_array()
1493 && ssa->vars[src_var].use_chain == op_1 in zend_dfa_optimize_op_array()
1494 && ssa->ops[op_1].op2_use_chain < 0 in zend_dfa_optimize_op_array()
1495 && !ssa->vars[src_var].phi_use_chain in zend_dfa_optimize_op_array()
1496 && !ssa->vars[src_var].sym_use_chain in zend_dfa_optimize_op_array()
1498 op_array, ssa, &op_array->opcodes[ssa->vars[src_var].definition], in zend_dfa_optimize_op_array()
1500 && !variable_defined_or_used_in_range(ssa, EX_VAR_TO_NUM(opline->op1.var), in zend_dfa_optimize_op_array()
1501 ssa->vars[src_var].definition+1, op_1) in zend_dfa_optimize_op_array()
1504 int op_2 = ssa->vars[src_var].definition; in zend_dfa_optimize_op_array()
1509 if (zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) { in zend_dfa_optimize_op_array()
1511 ssa->vars[v].definition = op_2; in zend_dfa_optimize_op_array()
1512 ssa->ops[op_2].result_def = v; in zend_dfa_optimize_op_array()
1514 ssa->vars[src_var].definition = -1; in zend_dfa_optimize_op_array()
1515 ssa->vars[src_var].use_chain = -1; in zend_dfa_optimize_op_array()
1517 ssa->ops[op_1].op1_use = -1; in zend_dfa_optimize_op_array()
1518 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1519 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1520 ssa->ops[op_1].op1_use_chain = -1; in zend_dfa_optimize_op_array()
1535 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1536 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1542 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1543 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1551 && ssa->ops[op_2].op1_use >= 0 in zend_dfa_optimize_op_array()
1552 …&& !(ssa->var_info[ssa->ops[op_2].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1558 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1559 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1567 && ssa->ops[op_2].op2_use >= 0 in zend_dfa_optimize_op_array()
1568 …&& !(ssa->var_info[ssa->ops[op_2].op2_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1576 ssa->ops[op_2].result_def = -1; in zend_dfa_optimize_op_array()
1577 ssa->ops[op_2].op1_def = v; in zend_dfa_optimize_op_array()
1578 ssa->ops[op_2].op1_use = ssa->ops[op_2].op2_use; in zend_dfa_optimize_op_array()
1579 ssa->ops[op_2].op1_use_chain = ssa->ops[op_2].op2_use_chain; in zend_dfa_optimize_op_array()
1580 ssa->ops[op_2].op2_use = -1; in zend_dfa_optimize_op_array()
1581 ssa->ops[op_2].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1586 && ssa->ops[op_1].op2_use >= 0 in zend_dfa_optimize_op_array()
1587 && ssa->ops[op_1].op2_def < 0) in zend_dfa_optimize_op_array()
1592 if (ssa->ops[op_1].op1_use != ssa->ops[op_1].op2_use) { in zend_dfa_optimize_op_array()
1593 zend_ssa_unlink_use_chain(ssa, op_1, orig_var); in zend_dfa_optimize_op_array()
1595 ssa->ops[op_1].op2_use_chain = ssa->ops[op_1].op1_use_chain; in zend_dfa_optimize_op_array()
1599 ssa->ops[op_1].result_def = v; in zend_dfa_optimize_op_array()
1600 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1601 ssa->ops[op_1].op1_use = ssa->ops[op_1].op2_use; in zend_dfa_optimize_op_array()
1602 ssa->ops[op_1].op1_use_chain = ssa->ops[op_1].op2_use_chain; in zend_dfa_optimize_op_array()
1603 ssa->ops[op_1].op2_use = -1; in zend_dfa_optimize_op_array()
1604 ssa->ops[op_1].op2_use_chain = -1; in zend_dfa_optimize_op_array()
1619 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1623 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1624 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1634 && ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1638 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1639 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_A… in zend_dfa_optimize_op_array()
1647 } else if (ssa->ops[op_1].op1_def == v in zend_dfa_optimize_op_array()
1649 && ssa->ops[op_1].op1_use >= 0 in zend_dfa_optimize_op_array()
1650 …&& !(ssa->var_info[ssa->ops[op_1].op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE… in zend_dfa_optimize_op_array()
1657 ssa->ops[op_1].result_def = ssa->ops[op_1].op1_def; in zend_dfa_optimize_op_array()
1658 ssa->ops[op_1].op1_def = -1; in zend_dfa_optimize_op_array()
1670 ssa_verify_integrity(op_array, ssa, "after dfa"); in zend_dfa_optimize_op_array()
1674 zend_ssa_remove_nops(op_array, ssa, ctx); in zend_dfa_optimize_op_array()
1676 ssa_verify_integrity(op_array, ssa, "after nop"); in zend_dfa_optimize_op_array()
1682 zend_dump_op_array(op_array, ZEND_DUMP_SSA, "after dfa pass", ssa); in zend_dfa_optimize_op_array()
1689 zend_ssa ssa; in zend_optimize_dfa() local
1691 if (zend_dfa_analyze_op_array(op_array, ctx, &ssa) != SUCCESS) { in zend_optimize_dfa()
1696 zend_dfa_optimize_op_array(op_array, ctx, &ssa, NULL); in zend_optimize_dfa()