Hi Sam, > This seems to suggest that block->loop_end() is the first block inside the loop, is this true?! If so, I hope it's clear why this is confusing :)
The comment on GetLoopEndRpo explains what loop_end is: // In Turbofan, the `block->loop_end()` refers to the first after (outside) // the loop. In the relevant use cases, we retrieve the backedge block by // subtracting one from the rpo_number, so for Turboshaft we "fake" this by // adding 1 to the backedge block's rpo_number. So, loop_end is outside of the loop. > Does the header have exactly one predecessor outside of the loop? Yes. > Is loop_end guaranteed to contain a backedge to the header? You might need a -1, cf the comment above, but yes. > Are other blocks allowed to have an edge back to the header? No. Cheers, Darius On Wednesday, June 25, 2025 at 9:40:39 PM UTC+2 sam.p...@arm.com wrote: > I think it's just the way that it's written, as it was suggested to me > offline that this annotation is describing a list of blocks: header -> end. > If this is true then it makes far more sense! Saying 'loop up to' has > certain connotations for me. > > I do have other questions about the properties of loops too though: > - Does the header have exactly one predecessor outside of the loop? > - Is loop_end guaranteed to contain a backedge to the header? > - Are other blocks allowed to have an edge back to the header? > > Thanks. > > > > On Wednesday, June 25, 2025 at 1:47:57 PM UTC+1 in...@bnoordhuis.nl wrote: > >> On Wed, Jun 25, 2025 at 12:06 PM Sam Parker-Haynes <sam.p...@arm.com> >> wrote: >> > >> > Hi! >> > >> > I'm looking at the backend and the terminology used for loops is really >> confusing me. AFAICT, in the backend there may be two special blocks for >> loops but I can't say it makes any sense to me! Here's the code that is >> boggling my mind: >> > >> > if (block->IsLoopHeader()) { >> > buffer << " (loop up to " << block->loop_end().ToInt() << ")"; >> > } >> > >> > This seems to suggest that block->loop_end() is the first block inside >> the loop, is this true?! If so, I hope it's clear why this is confusing :) >> > >> > cheers, >> > sam >> >> Nodes are visited in reverse post-order. Is that the source of the >> confusion? >> > -- -- v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/v8-dev/b47dfc1d-d39e-4b87-b543-525bc4ccbb31n%40googlegroups.com.