On Thu, 14 Aug 2014, Sebastian Pop wrote: > Richard Biener wrote: > > > > The following fixes missing dominator computation before fixing loops. > > Rather than doing even more such weird stuff in a pass gate function > > this puts this into a new pass scheduled before the loop passes gate. > > > > Ok. > > > +unsigned int > > +pass_fix_loops::execute (function *) > > +{ > > I would add an early exit if there are no loops in the function > (like in the original code below...) > > if (!loops_for_fn (fn)) > return 0;
Note that's not how things work today - loops_for_fn () returns non-NULL even for zero-loop functions as soon as we have CFG. The "hack" below was for -fdump-passes which calls each gate of every pass before the CFG is set up and thus would crash gate_loop if we didn't do that check. Of course -fdump-passes reports sth that is not true for all functions here. Richard. > > + if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) > > + { > > + calculate_dominance_info (CDI_DOMINATORS); > > + fix_loop_structure (NULL); > > + } > > + return 0; > > +} > > [...] > > > /* Gate for loop pass group. The group is controlled by > > -ftree-loop-optimize > > but we also avoid running it when the IL doesn't contain any loop. */ > > > > @@ -57,9 +107,6 @@ gate_loop (function *fn) > > if (!loops_for_fn (fn)) > > return true; > > ... here. > > > > > - /* Make sure to drop / re-discover loops when necessary. */ > > - if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) > > - fix_loop_structure (NULL); > > return number_of_loops (fn) > 1; > > } >