On Mon, 20 Jul 2015, Tom de Vries wrote:

> On 09/07/15 13:04, Richard Biener wrote:
> > On Thu, 9 Jul 2015, Tom de Vries wrote:
> > 
> > > On 07/07/15 17:58, Tom de Vries wrote:
> > > > > If you can
> > > > > handle one exit edge I also can't see the difficulty in handling
> > > > > all exit edges.
> > > > > 
> > > > 
> > > > Agreed, that doesn't look to complicated. I could call
> > > > rewrite_virtuals_into_loop_closed_ssa for all loops in
> > > > rewrite_virtuals_into_loop_closed_ssa, to get non-single_dom_exit loops
> > > > exercising the code, and fix what breaks.
> > > 
> > > Hmm, I just realised, it's more complicated than I thought.
> > > 
> > > In loops with single_dom_exit, the exit dominates the uses outside the
> > > loop,
> > > so I can replace the uses of the def with the uses of the exit phi result.
> > > 
> > > If !single_dom_exit, the exit(s) may not dominate all uses, and I need to
> > > insert non-loop-exit phi nodes to deal with that.
> > 
> > Yes.  This is why I originally suggested to amend the regular
> > loop-close-SSA rewriting code.
> > 
> 
> This patch renames rewrite_into_loop_closed_ssa to
> rewrite_into_loop_closed_ssa_1, and adds arguments:
> - a loop argument, to limit the defs for which the uses are
>   rewritten
> - a use_flags argument, to determine the type of uses rewritten:
>   SSA_OP_USE/SSA_OP_VIRTUAL_USES/SSA_OP_ALL_USES
> 
> The original rewrite_into_loop_closed_ssa is reimplemented using
> rewrite_into_loop_closed_ssa_1.
> 
> And the !single_dom_exit case of rewrite_into_loop_closed_ssa is implemented
> using rewrite_into_loop_closed_ssa_1. [ The patch was tested as attached,
> always using rewrite_into_loop_closed_ssa_1, otherwise it would not be
> triggered. ]
> 
> Bootstrapped and reg-tested on x86_64.
> 
> Is this sort of what you had in mind?

Yes.  New functions need a comment and instead of iterating over
all function BBs and checking bb->loop_father please use
get_loop_body ().

Of course in the final version #if 0 stuff shouldn't remain.  What's
the cost difference of removing the single_dom_exit special-case?

Thanks,
Richard.

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
Norton, HRB 21284 (AG Nuernberg)

Reply via email to