On Mon, Jan 20, 2020 at 2:39 AM <apin...@marvell.com> wrote: > > From: Andrew Pinski <apin...@marvell.com> > > Reported as PR 93321, prepare_block_for_update with some huge > recusive inlining can go past the stack limit. The loop > at the end, could be transformed such that the last iteration goes > back to the begining of the function instead of the call. > This reduces the stack usage and speeds up slightly > the function. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Can you instead change it to a worklist, see for example tree-ssa-pre.c:compute_avail for a recipe. OK with that change. Richard. > ChangeLog: > * tree-into-ssa.c (prepare_block_for_update): Manaually sibcall > optimize to self. > --- > gcc/tree-into-ssa.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c > index c27bf2ce121..6e139c3b056 100644 > --- a/gcc/tree-into-ssa.c > +++ b/gcc/tree-into-ssa.c > @@ -2616,6 +2616,7 @@ prepare_block_for_update (basic_block bb, bool > insert_phi_p) > edge e; > edge_iterator ei; > > +again: > mark_block_for_update (bb); > > /* Process PHI nodes marking interesting those that define or use > @@ -2695,10 +2696,17 @@ prepare_block_for_update (basic_block bb, bool > insert_phi_p) > } > > /* Now visit all the blocks dominated by BB. */ > - for (son = first_dom_son (CDI_DOMINATORS, bb); > - son; > - son = next_dom_son (CDI_DOMINATORS, son)) > - prepare_block_for_update (son, insert_phi_p); > + for (son = first_dom_son (CDI_DOMINATORS, bb); son; ) > + { > + basic_block next = next_dom_son (CDI_DOMINATORS, son); > + if (!next) > + { > + bb = son; > + goto again; > + } > + prepare_block_for_update (son, insert_phi_p); > + son = next; > + } > } > > > -- > 2.17.1 >