On Tue, 14 Sep 2021, Xionghu Luo wrote: > > > On 2021/9/13 16:17, Richard Biener wrote: > > [...] > > I don't understand - BB6 is the header block of loop 2 which is > > always entered and thus BB6 is always executed at least once. > > > > The important part is that BB4 which follows the inner loop is > > _not_ always executed because we don't know if we will exit the > > inner loop. > > > > What am I missing? > > Oh, I see. I only noticed the functionality change of the patch on the case > and no failure check of it, misunderstood it was a regression instead of an > improvement to also hoisting invariants from infinite loop, sorry about that. > > Finally, the function fill_always_executed_in_1 could mark all ALWAYS_EXECUTED > bb both including and after all subloops' bb but break after exiting from > infinite subloops with better performance, thanks. The only thing to be > worried is replacing get_loop_body_in_dom_order makes the code a bit more > complicated for later readers as the loop depth and DOM order is not a problem > here any more? ;)
Yeah, but embedding the DOM walk _does_ improve the runtime of the code and it would in principle allow to avoid entering conditionally executed loops that do not always terminate (that's something we could pre-compute and propagate up the loop tree). It's just it didn't seem worth adding even more code given I couldn't make the function pop up on the radar... Richard.