public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about creating an outermost loop
@ 2023-11-21  7:25 Hanke Zhang
  0 siblings, 0 replies; only message in thread
From: Hanke Zhang @ 2023-11-21  7:25 UTC (permalink / raw)
  To: gcc

Hi, I'm working on loop tiling recently. I want to add this
optimization to GCC. But I have encoutered some problems here and ask
for help.

For the code below as an example:

for (int i = 0; i < 12; i++) {
  for (int j = 0; j < arr.length; j++) { // arr.length may be huge
    // do something with arr[j]
  }
}

I want to create an outermost loop that wraps around the two loops of
the inner layer, and at the same time change the loop variables of the
innermost loop. The final result is as follows:

for (int k = 0; k < 8192; k++) {
  for (int i = 0; i < 12; i++) {
    for (int j = 0; j < arr.length / 8192; j++) {
      // do something with arr[k * (arr.length / 8192) + j]
    }
  }
}

But I don't know how to do this properly. I'm stuck with virtual
oprands and PHIs.

Is there any existing optimization in GCC that I can refer to?

Thanks.
Hanke Zhang.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-21  7:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21  7:25 Question about creating an outermost loop 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).