public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* The order of loop traversal in gcc
@ 2023-09-25  3:52 Hanke Zhang
  2023-09-25  5:46 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Hanke Zhang @ 2023-09-25  3:52 UTC (permalink / raw)
  To: gcc

Hi, I have recently been working on loops in gcc, and I have some
questions about the loop traversal.

I use loops_list(cfun, LI_ONLY_INNERMOST) to traverse the loops in my
pass to obtain the loop.

I found that the order of traversal and the order of actual
instruction execution will be different.

Sometimes it's the exact opposite, and sometimes it's sequential. I
would like to ask how to predict its behavior? And what method should
I use if I want to obtain sequential traversal?

Thanks.
Hanke Zhang.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The order of loop traversal in gcc
  2023-09-25  3:52 The order of loop traversal in gcc Hanke Zhang
@ 2023-09-25  5:46 ` Richard Biener
  2023-09-25  8:11   ` Hanke Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-09-25  5:46 UTC (permalink / raw)
  To: Hanke Zhang; +Cc: gcc



> Am 25.09.2023 um 04:53 schrieb Hanke Zhang via Gcc <gcc@gcc.gnu.org>:
> 
> Hi, I have recently been working on loops in gcc, and I have some
> questions about the loop traversal.
> 
> I use loops_list(cfun, LI_ONLY_INNERMOST) to traverse the loops in my
> pass to obtain the loop.
> 
> I found that the order of traversal and the order of actual
> instruction execution will be different.
> 
> Sometimes it's the exact opposite, and sometimes it's sequential. I
> would like to ask how to predict its behavior? And what method should
> I use if I want to obtain sequential traversal?

The order of loops is according to their index, if you require traversal in program order you have to order them yourself, for example by sorting them after their header program order.

Richard 

> Thanks.
> Hanke Zhang.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: The order of loop traversal in gcc
  2023-09-25  5:46 ` Richard Biener
@ 2023-09-25  8:11   ` Hanke Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Hanke Zhang @ 2023-09-25  8:11 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc

Richard Biener <richard.guenther@gmail.com> 于2023年9月25日周一 13:46写道:
>
>
>
> > Am 25.09.2023 um 04:53 schrieb Hanke Zhang via Gcc <gcc@gcc.gnu.org>:
> >
> > Hi, I have recently been working on loops in gcc, and I have some
> > questions about the loop traversal.
> >
> > I use loops_list(cfun, LI_ONLY_INNERMOST) to traverse the loops in my
> > pass to obtain the loop.
> >
> > I found that the order of traversal and the order of actual
> > instruction execution will be different.
> >
> > Sometimes it's the exact opposite, and sometimes it's sequential. I
> > would like to ask how to predict its behavior? And what method should
> > I use if I want to obtain sequential traversal?
>
> The order of loops is according to their index, if you require traversal in program order you have to order them yourself, for example by sorting them after their header program order.
>
> Richard
>

Thanks. Get it!

> > Thanks.
> > Hanke Zhang.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-25  8:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25  3:52 The order of loop traversal in gcc Hanke Zhang
2023-09-25  5:46 ` Richard Biener
2023-09-25  8:11   ` Hanke Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).