find_leader_in_sets (unsigned int val, bitmap_set_t set1, bitmap_set_t set2,
bitmap_set_t set3 = NULL)
{
- pre_expr result;
+ pre_expr result = NULL;
- result = bitmap_find_leader (set1, val);
+ if (set1)
+ result = bitmap_find_leader (set1, val);
if (!result && set2)
result = bitmap_find_leader (set2, val);
if (!result && set3)
static pre_expr
-phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, edge e);
+phi_translate (bitmap_set_t, pre_expr, bitmap_set_t, bitmap_set_t, edge);
/* Translate EXPR using phis in PHIBLOCK, so that it has the values of
the phis in PRED. Return NULL if we can't find a leader for each part
of the translated expression. */
static pre_expr
-phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, edge e)
+phi_translate_1 (bitmap_set_t dest,
+ pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, edge e)
{
basic_block pred = e->src;
basic_block phiblock = e->dest;
pre_expr leader, result;
unsigned int op_val_id = VN_INFO (newnary->op[i])->value_id;
leader = find_leader_in_sets (op_val_id, set1, set2);
- result = phi_translate (leader, set1, set2, e);
+ result = phi_translate (dest, leader, set1, set2, e);
if (result && result != leader)
- /* Force a leader as well as we are simplifying this
- expression. */
+ /* If op has a leader in the sets we translate make
+ sure to use the value of the translated expression.
+ We might need a new representative for that. */
newnary->op[i] = get_representative_for (result, pred);
else if (!result)
return NULL;
else
{
unsigned value_id = get_expr_value_id (constant);
- constant = find_leader_in_sets (value_id, set1, set2,
+ /* We want a leader in ANTIC_OUT or AVAIL_OUT here.
+ dest has what we computed into ANTIC_OUT sofar
+ so pick from that - since topological sorting
+ by sorted_array_from_bitmap_set isn't perfect
+ we may lose some cases here. */
+ constant = find_leader_in_sets (value_id, dest,
AVAIL_OUT (pred));
if (constant)
return constant;
}
op_val_id = VN_INFO (op[n])->value_id;
leader = find_leader_in_sets (op_val_id, set1, set2);
- opresult = phi_translate (leader, set1, set2, e);
+ opresult = phi_translate (dest, leader, set1, set2, e);
if (opresult && opresult != leader)
{
tree name = get_representative_for (opresult);
/* Wrapper around phi_translate_1 providing caching functionality. */
static pre_expr
-phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, edge e)
+phi_translate (bitmap_set_t dest, pre_expr expr,
+ bitmap_set_t set1, bitmap_set_t set2, edge e)
{
expr_pred_trans_t slot = NULL;
pre_expr phitrans;
}
/* Translate. */
- phitrans = phi_translate_1 (expr, set1, set2, e);
+ phitrans = phi_translate_1 (dest, expr, set1, set2, e);
if (slot)
{
FOR_EACH_VEC_ELT (exprs, i, expr)
{
pre_expr translated;
- translated = phi_translate (expr, set, NULL, e);
+ translated = phi_translate (dest, expr, set, NULL, e);
if (!translated)
continue;
gcc_assert (!(pred->flags & EDGE_FAKE));
bprime = pred->src;
/* We are looking at ANTIC_OUT of bprime. */
- eprime = phi_translate (expr, ANTIC_IN (block), NULL, pred);
+ eprime = phi_translate (NULL, expr, ANTIC_IN (block), NULL, pred);
/* eprime will generally only be NULL if the
value of the expression, translated
and so not come across fake pred edges. */
gcc_assert (!(pred->flags & EDGE_FAKE));
bprime = pred->src;
- eprime = phi_translate (expr, ANTIC_IN (block),
+ eprime = phi_translate (NULL, expr, ANTIC_IN (block),
PA_IN (block), pred);
/* eprime will generally only be NULL if the