On Mon, Jan 23, 2012 at 6:33 AM, Andrew Pinski
<andrew.pin...@caviumnetworks.com> wrote:
> Hi,
>  The problem here is not really jump threading getting in the way of
> PHI-OPT rather there is no cleanup of the IR after jump thread but
> before phi-opt.
> This patch adds a pass_phi_only_cprop right after the first vrp and
> pass_merge_phi right before the first and last phiopts.
>
> Since VRP does jump threading just like DOM does, we need a
> pass_phi_only_cprop right after it.  And the merge PHI pass should be
> done so that going into PHI-OPT we have a CFG which there is only one
> PHI for a case like:
> bb0:
> if (a)
>  goto L1;
> bb3:
> if (b) goto L2;
> L1:
> x = PHI <b(3), c(0)>
> L2:
>  x= PHI<x(L1), d(3)>
>
> PHI-OPT does not handle PHIs like this that well.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

The testcase already works for me on trunk, without your patch.

You are adding three passes - one of it phi_only_cprop which I'd rather
remove ... I suspect VRP simply exposes copy propagation opportunities,
and that's expected.  mergephi before phiopt makes sense, but then
we should move the first mergephi instead of inserting another one.

Richard.

> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * passes.c (init_optimization_passes): Add pass_phi_only_cprop after
> the first vpr pass.
> Add pass_merge_phi before the first and last phiopt passes.
>
> testsuite/ChangeLog:
> * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.

Reply via email to