Lines Matching refs:scdf
55 void scdf_mark_edge_feasible(scdf_ctx *scdf, int from, int to) { in scdf_mark_edge_feasible() argument
56 uint32_t edge = scdf_edge(&scdf->ssa->cfg, from, to); in scdf_mark_edge_feasible()
58 if (zend_bitset_in(scdf->feasible_edges, edge)) { in scdf_mark_edge_feasible()
64 zend_bitset_incl(scdf->feasible_edges, edge); in scdf_mark_edge_feasible()
66 if (!zend_bitset_in(scdf->executable_blocks, to)) { in scdf_mark_edge_feasible()
67 if (!zend_bitset_in(scdf->block_worklist, to)) { in scdf_mark_edge_feasible()
70 zend_bitset_incl(scdf->block_worklist, to); in scdf_mark_edge_feasible()
74 zend_ssa_block *ssa_block = &scdf->ssa->blocks[to]; in scdf_mark_edge_feasible()
77 zend_bitset_excl(scdf->phi_var_worklist, phi->ssa_var); in scdf_mark_edge_feasible()
78 scdf->handlers.visit_phi(scdf, phi); in scdf_mark_edge_feasible()
83 void scdf_init(zend_optimizer_ctx *ctx, scdf_ctx *scdf, zend_op_array *op_array, zend_ssa *ssa) { in scdf_init() argument
84 scdf->op_array = op_array; in scdf_init()
85 scdf->ssa = ssa; in scdf_init()
87 scdf->instr_worklist_len = zend_bitset_len(op_array->last); in scdf_init()
88 scdf->phi_var_worklist_len = zend_bitset_len(ssa->vars_count); in scdf_init()
89 scdf->block_worklist_len = zend_bitset_len(ssa->cfg.blocks_count); in scdf_init()
91 scdf->instr_worklist = zend_arena_calloc(&ctx->arena, in scdf_init()
92 …scdf->instr_worklist_len + scdf->phi_var_worklist_len + 2 * scdf->block_worklist_len + zend_bitset… in scdf_init()
95 scdf->phi_var_worklist = scdf->instr_worklist + scdf->instr_worklist_len; in scdf_init()
96 scdf->block_worklist = scdf->phi_var_worklist + scdf->phi_var_worklist_len; in scdf_init()
97 scdf->executable_blocks = scdf->block_worklist + scdf->block_worklist_len; in scdf_init()
98 scdf->feasible_edges = scdf->executable_blocks + scdf->block_worklist_len; in scdf_init()
100 zend_bitset_incl(scdf->block_worklist, 0); in scdf_init()
101 zend_bitset_incl(scdf->executable_blocks, 0); in scdf_init()
104 void scdf_solve(scdf_ctx *scdf, const char *name) { in scdf_solve() argument
105 zend_ssa *ssa = scdf->ssa; in scdf_solve()
107 while (!zend_bitset_empty(scdf->instr_worklist, scdf->instr_worklist_len) in scdf_solve()
108 || !zend_bitset_empty(scdf->phi_var_worklist, scdf->phi_var_worklist_len) in scdf_solve()
109 || !zend_bitset_empty(scdf->block_worklist, scdf->block_worklist_len) in scdf_solve()
112 while ((i = zend_bitset_pop_first(scdf->phi_var_worklist, scdf->phi_var_worklist_len)) >= 0) { in scdf_solve()
115 if (zend_bitset_in(scdf->executable_blocks, phi->block)) { in scdf_solve()
116 scdf->handlers.visit_phi(scdf, phi); in scdf_solve()
120 while ((i = zend_bitset_pop_first(scdf->instr_worklist, scdf->instr_worklist_len)) >= 0) { in scdf_solve()
122 if (zend_bitset_in(scdf->executable_blocks, block_num)) { in scdf_solve()
124 zend_op *opline = &scdf->op_array->opcodes[i]; in scdf_solve()
130 scdf->handlers.visit_instr(scdf, opline, ssa_op); in scdf_solve()
133 scdf_mark_edge_feasible(scdf, block_num, block->successors[0]); in scdf_solve()
135 scdf->handlers.mark_feasible_successors(scdf, block_num, block, opline, ssa_op); in scdf_solve()
141 while ((i = zend_bitset_pop_first(scdf->block_worklist, scdf->block_worklist_len)) >= 0) { in scdf_solve()
147 zend_bitset_incl(scdf->executable_blocks, i); in scdf_solve()
152 zend_bitset_excl(scdf->phi_var_worklist, phi->ssa_var); in scdf_solve()
153 scdf->handlers.visit_phi(scdf, phi); in scdf_solve()
159 scdf_mark_edge_feasible(scdf, i, block->successors[0]); in scdf_solve()
164 opline = &scdf->op_array->opcodes[j]; in scdf_solve()
165 zend_bitset_excl(scdf->instr_worklist, j); in scdf_solve()
167 scdf->handlers.visit_instr(scdf, opline, &ssa->ops[j]); in scdf_solve()
171 scdf_mark_edge_feasible(scdf, i, block->successors[0]); in scdf_solve()
177 scdf->handlers.mark_feasible_successors(scdf, i, block, opline, &ssa->ops[j-1]); in scdf_solve()
187 static zend_bool kept_alive_by_live_range(scdf_ctx *scdf, uint32_t block) { in kept_alive_by_live_range() argument
189 const zend_op_array *op_array = scdf->op_array; in kept_alive_by_live_range()
190 const zend_cfg *cfg = &scdf->ssa->cfg; in kept_alive_by_live_range()
197 && zend_bitset_in(scdf->executable_blocks, start_block)) { in kept_alive_by_live_range()
207 int scdf_remove_unreachable_blocks(scdf_ctx *scdf) { in scdf_remove_unreachable_blocks() argument
208 zend_ssa *ssa = scdf->ssa; in scdf_remove_unreachable_blocks()
213 if (!zend_bitset_in(scdf->executable_blocks, i) in scdf_remove_unreachable_blocks()
215 && !kept_alive_by_live_range(scdf, i)) { in scdf_remove_unreachable_blocks()
217 zend_ssa_remove_block(scdf->op_array, ssa, i); in scdf_remove_unreachable_blocks()