This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] tree-ssa-sink.c: Simplify/improve code sinking.
- From: Jeffrey A Law <law at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, dberlin at dberlin dot org
- Date: Wed, 06 Apr 2005 11:29:32 -0600
- Subject: Re: [patch] tree-ssa-sink.c: Simplify/improve code sinking.
- Organization: Red Hat, Inc
- References: <20050406.111043.58455778.kazu@cs.umass.edu>
- Reply-to: law at redhat dot com
On Wed, 2005-04-06 at 11:10 -0400, Kazu Hirata wrote:
> Hi,
>
> Attached is a patch to simplify/improve code sinking.
>
> Given a statement, the code sinking in tree-ssa-sink.c computes a
> location to sink a statement into by finding the nearest common
> dominator of all uses of the statement's result. To do so, it goes
> through immediate uses of the statement's result.
>
> It turns out that nearest_common_dominator_of_uses are going through
> things more than immediate uses. Specifically, it was going through
> all PHI arguments of a PHI node where at least one use occurs. Since
> uses of operands in PHI arguments are considered to occur in
> predecessors of edges going into a PHI node, we are computing the
> nearest common dominator of a larger set of basic blocks, which
> obviously makes the result of nearest_common_dominator_of_uses
> unnecessarily higher in the dominator tree.
>
> The patch fixes this problem by visiting a PHI argument where a use
> actually occurs. Fortunately, Andrew MacLeod introduced a new gadget
> PHI_ARG_INDEX_FROM_USE, so we don't have to use a "for" loop to find a
> PHI argument where a use occurs.
>
> This patch is compile-time neutral, even when I use bootstrapped
> compilers. After all, the "for" loop in question isn't a hot place.
>
> Without patch, this pass sinks 2079 statements while compiling cc1-i
> files. With this patch, it sinks 2179 statements. A few statements
> are sunk deeper with this patch.
>
> Tested on i686-pc-linux-gnu. OK to apply?
>
> Kazu Hirata
>
> 2005-04-06 Kazu Hirata <kazu@cs.umass.edu>
>
> * tree-ssa-sink.c (nearest_common_dominator_of_uses): Look at
> a PHI argument where a use occurs instead of all PHI arguments.
This is fine. THanks,
Jeff