/* Coalesce the partitions in MAP representing VAR1 and VAR2 if it is valid.
Choose a representative for the partition, and send debug info to DEBUG. */
-static void
+static bool
copy_rename_partition_coalesce (var_map map, tree var1, tree var2, FILE *debug)
{
int p1, p2, p3;
{
if (debug)
fprintf (debug, " : Already coalesced.\n");
- return;
+ return false;
}
/* Don't coalesce if one of the variables occurs in an abnormal PHI. */
{
if (debug)
fprintf (debug, " : Abnormal PHI barrier. No coalesce.\n");
- return;
+ return false;
}
/* Partitions already have the same root, simply merge them. */
p1 = partition_union (map->var_partition, p1, p2);
if (debug)
fprintf (debug, " : Same root, coalesced --> P%d.\n", p1);
- return;
+ return false;
}
/* Never attempt to coalesce 2 difference parameters. */
{
if (debug)
fprintf (debug, " : 2 different PARM_DECLS. No coalesce.\n");
- return;
+ return false;
}
if ((TREE_CODE (root1) == RESULT_DECL) != (TREE_CODE (root2) == RESULT_DECL))
{
if (debug)
fprintf (debug, " : One root a RESULT_DECL. No coalesce.\n");
- return;
+ return false;
}
ign1 = TREE_CODE (root1) == VAR_DECL && DECL_IGNORED_P (root1);
{
if (debug)
fprintf (debug, " : 2 different USER vars. No coalesce.\n");
- return;
+ return false;
}
}
{
if (debug)
fprintf (debug, " : 2 memory tags. No coalesce.\n");
- return;
+ return false;
}
/* If both values have default defs, we can't coalesce. If only one has a
{
if (debug)
fprintf (debug, " : 2 default defs. No coalesce.\n");
- return;
+ return false;
}
else
{
}
/* Don't coalesce if the two variables aren't type compatible. */
- if (!lang_hooks.types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
+ if (!types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
{
if (debug)
fprintf (debug, " : Incompatible types. No coalesce.\n");
- return;
+ return false;
}
/* Don't coalesce if the aliasing sets of the types are different. */
{
if (debug)
fprintf (debug, " : 2 different aliasing sets. No coalesce.\n");
- return;
+ return false;
}
TDF_SLIM);
fprintf (debug, "\n");
}
+ return true;
}
tree phi, stmt, var, part_var;
unsigned x;
FILE *debug;
+ bool updated = false;
if (dump_file && (dump_flags & TDF_DETAILS))
debug = dump_file;
tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
if (TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs) == SSA_NAME)
- copy_rename_partition_coalesce (map, lhs, rhs, debug);
+ updated |= copy_rename_partition_coalesce (map, lhs, rhs, debug);
}
}
}
{
tree arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) == SSA_NAME)
- copy_rename_partition_coalesce (map, res, arg, debug);
+ updated |= copy_rename_partition_coalesce (map, res, arg, debug);
}
}
}
}
delete_var_map (map);
- return 0;
+ return updated ? TODO_remove_unused_locals : 0;
}
/* Return true if copy rename is to be performed. */