#include "tv.h"
#include "opt_confirms.h"
-//#define AVOID_PHIB
+#undef AVOID_PHIB
DEBUG_ONLY(static firm_dbg_module_t *dbg);
ir_node *phi;
ir_node **in;
- // This is needed because we create bads sometimes
+ /* This is needed because we create bads sometimes */
if(is_Bad(block))
return new_Bad();
- // already processed this block?
+ /* already processed this block? */
if(irn_visited(block)) {
ir_node *value = (ir_node*) get_irn_link(block);
return value;
irg = get_irn_irg(block);
assert(block != get_irg_start_block(irg));
- // blocks with only 1 pred need no phi
+ /* a Blocks with only 1 predecessor need no Phi */
n_cfgpreds = get_Block_n_cfgpreds(block);
if(n_cfgpreds == 1) {
ir_node *pred_block = get_Block_cfgpred_block(block, 0);
return value;
}
- // create a new phi
+ /* create a new Phi */
NEW_ARR_A(ir_node*, in, n_cfgpreds);
for(i = 0; i < n_cfgpreds; ++i)
in[i] = new_Unknown(mode);
set_irn_link(block, phi);
mark_irn_visited(block);
- // set phi preds
+ /* set Phi predecessors */
for(i = 0; i < n_cfgpreds; ++i) {
ir_node *pred_block = get_Block_cfgpred_block(block, i);
ir_node *pred_val = search_def_and_create_phis(pred_block, mode);
mark_irn_visited(value_block);
}
- // Only fix the users of the first, i.e. the original node
+ /* Only fix the users of the first, i.e. the original node */
value = vals[0];
foreach_out_edge_safe(value, edge, next) {
ir_node *user_block = get_nodes_block(user);
ir_node *newval;
- // ignore keeps
- if(get_irn_op(user) == op_End)
+ /* ignore keeps */
+ if (is_End(user))
continue;
if (user_block == blocks[1])
newval = search_def_and_create_phis(user_block, mode);
}
- // don't fix newly created phis from the SSA construction
+ /* don't fix newly created Phis from the SSA construction */
if (newval != user) {
DB((dbg, LEVEL_4, ">>>> Setting input %d of %+F to %+F\n", j, user, newval));
set_irn_n(user, j, newval);
typedef struct condeval_env_t {
ir_node *true_block;
ir_node *cmp; /**< The Compare node that might be partial evaluated */
- pn_Cmp pnc; /**< The Compare mode of teh Compare node. */
+ pn_Cmp pnc; /**< The Compare mode of the Compare node. */
ir_node *cnst;
tarval *tv;
unsigned long visited_nr;
/* we can evaluate Phis right now, all other nodes get copied */
if (is_Phi(node)) {
copy = get_Phi_pred(node, j);
- /* we might have to evaluate a phi-cascades */
+ /* we might have to evaluate a Phi-cascade */
if(get_irn_visited(copy) >= env->visited_nr) {
copy = get_irn_link(copy);
}
if (mode == mode_X || is_Cond(node))
continue;
#ifdef AVOID_PHIB
- /* we may not copy mode_b nodes, because this could produce phi with
+ /* we may not copy mode_b nodes, because this could produce Phi with
* mode_bs which can't be handled in all backends. Instead we duplicate
* the node and move it to its users */
if (mode == mode_b) {
copy = copy_and_fix_node(env, block, copy_block, j, node);
/* we might hit values in blocks that have already been processed by a
- * recursive find_phi_with_const call */
+ * recursive find_phi_with_const() call */
assert(get_irn_visited(copy) <= env->visited_nr);
if(get_irn_visited(copy) >= env->visited_nr) {
ir_node *prev_copy = get_irn_link(copy);
return get_Const_tarval(node);
}
-static ir_node *find_const(condeval_env_t *env, ir_node *jump, ir_node *value)
+static ir_node *find_const_or_confirm(condeval_env_t *env, ir_node *jump, ir_node *value)
{
ir_node *block = get_nodes_block(jump);
env->true_block, block
));
- // adjust true_block to point directly towards our jump
+ /* adjust true_block to point directly towards our jump */
add_pred(env->true_block, jump);
split_critical_edge(env->true_block, 0);
- // we need a bigger visited nr when going back
+ /* we need a bigger visited nr when going back */
env->visited_nr++;
return block;
if(is_Phi(value)) {
int i, arity;
- /* the phi has to be in the same block as the jump */
+ /* the Phi has to be in the same Block as the Jmp */
if(get_nodes_block(value) != block) {
return NULL;
}
ir_node *phi_pred = get_Phi_pred(value, i);
ir_node *cfgpred = get_Block_cfgpred(block, i);
- copy_block = find_const(env, cfgpred, phi_pred);
+ copy_block = find_const_or_confirm(env, cfgpred, phi_pred);
if(copy_block == NULL)
continue;
env->true_block, block
));
- // adjust true_block to point directly towards our jump
+ /* adjust true_block to point directly towards our jump */
add_pred(env->true_block, jump);
split_critical_edge(env->true_block, 0);
- // we need a bigger visited nr when going back
+ /* we need a bigger visited nr when going back */
env->visited_nr++;
return block;
if(is_Phi(value)) {
int i, arity;
- // the phi has to be in the same block as the jump
+ /* the Phi has to be in the same Block as the Jmp */
if(get_nodes_block(value) != block)
return NULL;
env->cnst_pos = i;
}
- // return now as we can't process more possibilities in 1 run
+ /* return now as we can't process more possibilities in 1 run */
return copy_block;
}
}
pnc = get_negated_pnc(pnc, get_irn_mode(right));
}
- // (recursively) look if a pred of a phi is a constant
+ /* (recursively) look if a pred of a Phi is a constant or a Confirm */
env->cmp = cmp;
env->pnc = pnc;
env->cnst = right;
- return find_const(env, jump, left);
+ return find_const_or_confirm(env, jump, left);
}
return NULL;
return;
selector = get_Cond_selector(cond);
- // TODO handle switch Conds
+ /* TODO handle switch Conds */
if (get_irn_mode(selector) != mode_b)
return;
return;
}
- // (recursively) look if a pred of a phi is a constant
+ /* (recursively) look if a pred of a Phi is a constant or a Confirm */
env.true_block = block;
inc_irg_visited(current_ir_graph);
env.visited_nr = get_irg_visited(current_ir_graph);
return;
/* we have to remove the edge towards the pred as the pred now
- * jumps into the true_block. We also have to shorten phis
+ * jumps into the true_block. We also have to shorten Phis
* in our block because of this */
bad = new_Bad();
cnst_pos = env.cnst_pos;
- /* shorten phis */
+ /* shorten Phis */
foreach_out_edge_safe(env.cnst_pred, edge, next) {
ir_node *node = get_edge_src_irn(edge);