/* The number of new PHI nodes added by PRE. */
int phis;
-
- /* The number of values found constant. */
- int constified;
-
} pre_stats;
static bool do_partial_partial;
return;
}
}
+
+ gcc_unreachable ();
}
/* Return true if two bitmap sets are equal. */
break;
case 3:
folded = fold_build3 (nary->opcode, nary->type,
- genop[0], genop[1], genop[3]);
+ genop[0], genop[1], genop[2]);
break;
default:
gcc_unreachable ();
FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
- if (expr->kind != NAME)
+ if (expr->kind == NARY
+ || expr->kind == REFERENCE)
{
pre_expr *avail;
unsigned int val;
/* If all edges produce the same value and that value is
an invariant, then the PHI has the same value on all
edges. Note this. */
- else if (!cant_insert && all_same && eprime
- && (edoubleprime->kind == CONSTANT
- || edoubleprime->kind == NAME)
- && !value_id_constant_p (val))
+ else if (!cant_insert && all_same)
{
- unsigned int j;
- bitmap_iterator bi;
- bitmap_set_t exprset = VEC_index (bitmap_set_t,
- value_expressions, val);
+ tree exprtype = get_expr_type (expr);
+ tree temp;
+ gimple assign;
+ pre_expr newe;
+ gimple_stmt_iterator gsi;
- unsigned int new_val = get_expr_value_id (edoubleprime);
- FOR_EACH_EXPR_ID_IN_SET (exprset, j, bi)
- {
- pre_expr expr = expression_for_id (j);
+ gcc_assert (edoubleprime->kind == CONSTANT
+ || edoubleprime->kind == NAME);
- if (expr->kind == NAME)
- {
- vn_ssa_aux_t info = VN_INFO (PRE_EXPR_NAME (expr));
- /* Just reset the value id and valnum so it is
- the same as the constant we have discovered. */
- if (edoubleprime->kind == CONSTANT)
- {
- info->valnum = PRE_EXPR_CONSTANT (edoubleprime);
- pre_stats.constified++;
- }
- else
- info->valnum = VN_INFO (PRE_EXPR_NAME (edoubleprime))->valnum;
- info->value_id = new_val;
- }
+ if (!pretemp || TREE_TYPE (pretemp) != exprtype)
+ {
+ pretemp = create_tmp_reg (exprtype, "pretmp");
+ add_referenced_var (pretemp);
}
+ temp = make_ssa_name (pretemp, NULL);
+ assign = gimple_build_assign (temp,
+ edoubleprime->kind == CONSTANT ? PRE_EXPR_CONSTANT (edoubleprime) : PRE_EXPR_NAME (edoubleprime));
+ gsi = gsi_after_labels (block);
+ gsi_insert_before (&gsi, assign, GSI_NEW_STMT);
+
+ gimple_set_plf (assign, NECESSARY, false);
+ VN_INFO_GET (temp)->value_id = val;
+ VN_INFO (temp)->valnum = temp;
+ bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (temp));
+ newe = get_or_alloc_expr_for_name (temp);
+ add_to_value (val, newe);
+ bitmap_value_replace_in_set (AVAIL_OUT (block), newe);
+ bitmap_insert_into_set (NEW_SETS (block), newe);
}
free (avail);
}
FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
{
- if (expr->kind != NAME)
+ if (expr->kind == NARY
+ || expr->kind == REFERENCE)
{
pre_expr *avail;
unsigned int val;
statistics_counter_event (cfun, "PA inserted", pre_stats.pa_insert);
statistics_counter_event (cfun, "New PHIs", pre_stats.phis);
statistics_counter_event (cfun, "Eliminated", pre_stats.eliminations);
- statistics_counter_event (cfun, "Constified", pre_stats.constified);
clear_expression_ids ();
if (!do_fre)