This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC][12/13]Workaround reduction statements for distribution
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <Bin dot Cheng at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Fri, 16 Jun 2017 12:21:17 +0200
- Subject: Re: [PATCH GCC][12/13]Workaround reduction statements for distribution
- Authentication-results: sourceware.org; auth=none
- References: <VI1PR0802MB2176C35CBA70FB170B6E331AE7CD0@VI1PR0802MB2176.eurprd08.prod.outlook.com>
On Mon, Jun 12, 2017 at 7:03 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> For now, loop distribution handles variables used outside of loop as reduction.
> This is inaccurate because all partitions contain statement defining induction
> vars.
But final induction values are usually not used outside of the loop...
What is missing is loop distribution trying to change partition order. In fact
we somehow assume we can move a reduction across a detected builtin
(I don't remember if we ever check for validity of that...).
> Ideally we should factor out scev-propagation as a standalone interface
> which can be called when necessary. Before that, this patch simply workarounds
> reduction issue by checking if the statement belongs to all partitions. If yes,
> the reduction must be computed in the last partition no matter how the loop is
> distributed.
> Bootstrap and test on x86_64 and AArch64. Is it OK?
stmt_in_all_partitions is not kept up-to-date during partition merging and if
merging makes the reduction partition(s) pass the stmt_in_all_partitions
test your simple workaround doesn't work ...
As written it's a valid optimization but can you please note it's limitation in
some comment please?
Also...
+ bitmap_set_range (stmt_in_all_partitions, 0, rdg->n_vertices);
+ rdg_build_partitions (rdg, stmts, &partitions, stmt_in_all_partitions);
ick. Please instead do
bitmap_copy (smtt_in_all_partitions, partitions[0]->stmts);
for (i = 1; i < ...)
bitmap_and_into (stmt_in_all_partitons, partitions[i]->stmts);
Thanks,
Richard.
> Thanks,
> bin
> 2017-06-07 Bin Cheng <bin.cheng@arm.com>
>
> * tree-loop-distribution.c (classify_partition): New parameter and
> better handle reduction statement.
> (rdg_build_partitions): New parameter and record statements belonging
> to all partitions.
> (distribute_loop): Update use of above functions.