On Mon, Jun 09, 2025 at 07:46:28PM +0200, Jakub Jelinek wrote: > > So using, say, get_all_dominated_blocks (we free dominators, possibly > > PHI expansion might insert on edges) to get a PRE ordered set of > > I think PHI expansion does insert on edges.
As for whether to expand in some different order, right now the patch just uses ranger on demand only in cases when we need to know, I think that is something done in many passes even when they don't process basic blocks in some particular order (and after all, if processing of each stmt in the bbs doesn't necessarily lead to any ranger action, I'm not sure why it would matter). I can certainly try to expand in different order if it would be helpful. But currently /* Dominators are not kept up-to-date as we may create new basic-blocks. */ free_dominance_info (CDI_DOMINATORS); and init_block = construct_init_block (); certainly creates new bb (BB_RTL) as new successor of ENTRY and makes it dominate the former ENTRY successor if any. Plus expand_gimple_basic_block can create further bbs (again BB_RTL) or remove edges. Though probably the newly created bbs will be given higher indexes and so saving the bb numbers from before the free_dominance_info call and using it to order the bbs might work. Jakub