On Tue, 15 Jun 2021, Aldy Hernandez wrote: > > > On 6/14/21 4:04 PM, Richard Biener wrote: > > The same issue that arises in PR100934 can happen in the backward > > threader now (Aldy?) - we eventually run into mark_irreducible_loops > > for non-FSM thread paths checking for paths crossing irreducible > > region boundaries. > > I haven't been following the above PR, so I may be missing something, but it > seems like you would need to twiddle all users of the path registry, not just > the backwards threader.
Yes, VRP already uses LOOPS_NORMAL, I fixed DOM with the patch for PR100934. That leaves the backwards threader, so after this change all consumers should be fixed. The question was more like if we'd ever run into the code in mark_threaded_blocks that reads /* Look for jump threading paths which cross multiple loop headers. The code to thread through loop headers will change the CFG in ways that invalidate the cached loop iteration information. So we must detect that case and wipe the cached information. */ EXECUTE_IF_SET_IN_BITMAP (tmp, 0, i, bi) ... we're definitely executing mark_threaded_blocks but we've executed and pruned all FSM threading paths before. I suppose I should simply place the assert there and see what happens when I don't fixup the backwards threader ... Richard. > > > > /* Try to thread each block with more than one successor. */ > > thread_jumps threader (/*speed_p=*/false); > > diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c > > index a86302be18e..387994fd882 100644 > > --- a/gcc/tree-ssa-threadupdate.c > > +++ b/gcc/tree-ssa-threadupdate.c > > @@ -1917,6 +1917,8 @@ jump_thread_path_registry::mark_threaded_blocks > > (bitmap threaded_blocks) > > edge e; > > edge_iterator ei; > > + gcc_assert (loops_state_satisfies_p > > (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)); > > + > > /* It is possible to have jump threads in which one is a subpath > > of the other. ie, (A, B), (B, C), (C, D) where B is a joiner > > block and (B, C), (C, D) where no joiner block exists. > > > > If you're asserting this, don't you need to initialize DOM and VRP with > LOOPS_MAY_HAVE_MARKED_IRREDUCIBLE_REGIONS as well? They may use the registry > via their jump_threader. > > Hmmm...tree-vrp seems fine: > > loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); > > because LOOPS_NORMAL includes LOOPS_MAY_HAVE_MARKED_IRREDUCIBLE_REGIONS. > > But you may need some massaging in DOM: > > loop_optimizer_init (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES); > > Aldy > > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)