Commit 821dbeef by Bin Cheng Committed by Bin Cheng

tree-loop-distribution.c (enum fuse_type, [...]): New.

	* tree-loop-distribution.c (enum fuse_type, fuse_message): New.
	(partition_merge_into): New parameter.  Dump reason for fusion.
	(distribute_loop): Update use of partition_merge_into.

From-SVN: r249986
parent 3be57c56
2017-07-05 Bin Cheng <bin.cheng@arm.com> 2017-07-05 Bin Cheng <bin.cheng@arm.com>
* tree-loop-distribution.c (enum fuse_type, fuse_message): New.
(partition_merge_into): New parameter. Dump reason for fusion.
(distribute_loop): Update use of partition_merge_into.
2017-07-05 Bin Cheng <bin.cheng@arm.com>
* tree-loop-distribution.c (bb_top_order_index): New. * tree-loop-distribution.c (bb_top_order_index): New.
(bb_top_order_index_size, bb_top_order_cmp): New. (bb_top_order_index_size, bb_top_order_cmp): New.
(stmts_from_loop): Use topological order. (stmts_from_loop): Use topological order.
......
...@@ -545,15 +545,42 @@ partition_reduction_p (partition *partition) ...@@ -545,15 +545,42 @@ partition_reduction_p (partition *partition)
return partition->reduction_p; return partition->reduction_p;
} }
/* Partitions are fused because of different reasons. */
enum fuse_type
{
FUSE_NON_BUILTIN = 0,
FUSE_REDUCTION = 1,
FUSE_SHARE_REF = 2,
FUSE_SAME_SCC = 3,
FUSE_FINALIZE = 4
};
/* Description on different fusing reason. */
static const char *fuse_message[] = {
"they are non-builtins",
"they have reductions",
"they have shared memory refs",
"they are in the same dependence scc",
"there is no point to distribute loop"};
/* Merge PARTITION into the partition DEST. */ /* Merge PARTITION into the partition DEST. */
static void static void
partition_merge_into (partition *dest, partition *partition) partition_merge_into (partition *dest, partition *partition, enum fuse_type ft)
{ {
dest->kind = PKIND_NORMAL; dest->kind = PKIND_NORMAL;
bitmap_ior_into (dest->stmts, partition->stmts); bitmap_ior_into (dest->stmts, partition->stmts);
if (partition_reduction_p (partition)) if (partition_reduction_p (partition))
dest->reduction_p = true; dest->reduction_p = true;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Fuse partitions because %s:\n", fuse_message[ft]);
fprintf (dump_file, " Part 1: ");
dump_bitmap (dump_file, dest->stmts);
fprintf (dump_file, " Part 2: ");
dump_bitmap (dump_file, partition->stmts);
}
} }
...@@ -1531,13 +1558,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts, ...@@ -1531,13 +1558,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
for (++i; partitions.iterate (i, &partition); ++i) for (++i; partitions.iterate (i, &partition); ++i)
if (!partition_builtin_p (partition)) if (!partition_builtin_p (partition))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) partition_merge_into (into, partition, FUSE_NON_BUILTIN);
{
fprintf (dump_file, "fusing non-builtin partitions\n");
dump_bitmap (dump_file, into->stmts);
dump_bitmap (dump_file, partition->stmts);
}
partition_merge_into (into, partition);
partitions.unordered_remove (i); partitions.unordered_remove (i);
partition_free (partition); partition_free (partition);
i--; i--;
...@@ -1553,14 +1574,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts, ...@@ -1553,14 +1574,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
for (i = i + 1; partitions.iterate (i, &partition); ++i) for (i = i + 1; partitions.iterate (i, &partition); ++i)
if (partition_reduction_p (partition)) if (partition_reduction_p (partition))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) partition_merge_into (into, partition, FUSE_REDUCTION);
{
fprintf (dump_file, "fusing partitions\n");
dump_bitmap (dump_file, into->stmts);
dump_bitmap (dump_file, partition->stmts);
fprintf (dump_file, "because they have reductions\n");
}
partition_merge_into (into, partition);
partitions.unordered_remove (i); partitions.unordered_remove (i);
partition_free (partition); partition_free (partition);
i--; i--;
...@@ -1578,15 +1592,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts, ...@@ -1578,15 +1592,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
{ {
if (similar_memory_accesses (rdg, into, partition)) if (similar_memory_accesses (rdg, into, partition))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) partition_merge_into (into, partition, FUSE_SHARE_REF);
{
fprintf (dump_file, "fusing partitions\n");
dump_bitmap (dump_file, into->stmts);
dump_bitmap (dump_file, partition->stmts);
fprintf (dump_file, "because they have similar "
"memory accesses\n");
}
partition_merge_into (into, partition);
partitions.unordered_remove (j); partitions.unordered_remove (j);
partition_free (partition); partition_free (partition);
j--; j--;
...@@ -1678,15 +1684,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts, ...@@ -1678,15 +1684,7 @@ distribute_loop (struct loop *loop, vec<gimple *> stmts,
for (j = j + 1; partitions.iterate (j, &partition); ++j) for (j = j + 1; partitions.iterate (j, &partition); ++j)
if (pg->vertices[j].component == i) if (pg->vertices[j].component == i)
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) partition_merge_into (first, partition, FUSE_SAME_SCC);
{
fprintf (dump_file, "fusing partitions\n");
dump_bitmap (dump_file, first->stmts);
dump_bitmap (dump_file, partition->stmts);
fprintf (dump_file, "because they are in the same "
"dependence SCC\n");
}
partition_merge_into (first, partition);
partitions[j] = NULL; partitions[j] = NULL;
partition_free (partition); partition_free (partition);
PGDATA (j)->partition = NULL; PGDATA (j)->partition = NULL;
......
Markdown is supported
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