Commit 008417ce authored by Matthias Braun's avatar Matthias Braun
Browse files

occult_const: cleanup

parent b16f3427
......@@ -30,22 +30,22 @@
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
typedef struct env_t {
bool changed;
bool changed;
ir_nodemap dca;
struct obstack obst;
} env_t;
static void occult_const_opt_walker(ir_node *node, void *data)
{
/* Ignore already const nodes */
if (is_Address(node) || is_Align(node) || is_Const(node) || is_Offset(node) || is_Size(node)) return;
if (is_irn_constlike(node))
return;
/* Ignore mode_BB, mode_X, etc */
if (!mode_is_data(get_irn_mode(node))) return;
if (!mode_is_data(get_irn_mode(node)))
return;
env_t *env = (env_t *)data;
env_t *env = (env_t*)data;
bitinfo *vrp = get_bitinfo(node);
if (vrp == NULL) {
DB((dbg, LEVEL_4, "No VRP info: %+F\n", node));
return;
......@@ -55,14 +55,16 @@ static void occult_const_opt_walker(ir_node *node, void *data)
ir_tarval *not_const_bits = tarval_eor(vrp->o, vrp->z);
ir_tarval *relevant_not_const_bits = tarval_and(dc, not_const_bits);
if (!tarval_is_null(relevant_not_const_bits)) {
DB((dbg, LEVEL_4, "Not occult: %+F dc=%T, z=%T, o=%T\n", node, dc, vrp->z, vrp->o));
DB((dbg, LEVEL_4, "Not occult: %+F dc=%T, z=%T, o=%T\n", node, dc,
vrp->z, vrp->o));
return;
}
ir_graph *irg = get_irn_irg(node);
ir_tarval *tv = tarval_and(vrp->z, dc);
ir_node *cnst = new_r_Const(irg, tv);
DB((dbg, LEVEL_2, "Occult Const found: %+F -> %+F dc=%T, z=%T, o=%T\n", node, cnst, dc, vrp->z, vrp->o));
DB((dbg, LEVEL_2, "Occult Const found: %+F -> %+F dc=%T, z=%T, o=%T\n",
node, cnst, dc, vrp->z, vrp->o));
exchange(node, cnst);
env->changed = true;
}
......@@ -76,24 +78,15 @@ void occult_consts(ir_graph *irg)
{
FIRM_DBG_REGISTER(dbg, "firm.opt.occults");
assure_irg_properties(irg,
IR_GRAPH_PROPERTY_NO_BADS
| IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
| IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES);
constbits_analyze(irg);
env_t env;
env.changed = false;
obstack_init(&env.obst);
constbits_analyze(irg);
memset(&env, 0, sizeof(env));
ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
dca_analyze(irg);
ir_nodemap_init(&env.dca, irg);
irg_walk_graph(irg, fill_nodemap, 0, &env.dca);
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
irg_walk_graph(irg, occult_const_opt_walker, 0, &env);
......@@ -101,7 +94,6 @@ void occult_consts(ir_graph *irg)
ir_nodemap_destroy(&env.dca);
constbits_clear(irg);
obstack_free(&env.obst, NULL);
confirm_irg_properties(irg,
env.changed ? IR_GRAPH_PROPERTIES_NONE : IR_GRAPH_PROPERTIES_ALL);
}
Supports Markdown
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