Commit 6da87fa5 authored by Matthias Braun's avatar Matthias Braun
Browse files

ldstopt: fix corner case in phi(store, store) opt

We first have to create the new replacement store after the phi, so the
following removal of the old nodes does not assume the ptr input value is
unused and kills it.
parent b4d1adc7
......@@ -1432,23 +1432,19 @@ static unsigned optimize_phi(ir_node *phi, walk_env_t *wenv)
/* third step: create a new data Phi */
ir_node *phiD = new_rd_Phi(get_irn_dbg_info(phi), block, n, inD, mode);
/* rewire memory and kill the node */
for (int i = n - 1; i >= 0; --i) {
ir_node *proj = projMs[i];
if (is_Proj(proj)) {
ir_node *store = get_Proj_pred(proj);
exchange(proj, inM[i]);
kill_and_reduce_usage(store);
}
}
/* fourth step: create the Store */
store = new_rd_Store(db, block, phiM, ptr, phiD, cons_none);
projM = new_rd_Proj(NULL, store, mode_M, pn_Store_M);
/* rewire memory and kill the old nodes */
for (int i = n - 1; i >= 0; --i) {
ir_node *proj = projMs[i];
assert(is_Proj(proj));
ir_node *store = get_Proj_pred(proj);
exchange(proj, inM[i]);
kill_and_reduce_usage(store);
}
info = get_ldst_info(store, &wenv->obst);
info->projs[pn_Store_M] = projM;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment