public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115385] New: Peeling for gaps can be optimized more or needs to peel more than one iteration
@ 2024-06-07 11:44 rguenth at gcc dot gnu.org
  2024-06-07 11:59 ` [Bug tree-optimization/115385] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-07 11:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115385

            Bug ID: 115385
           Summary: Peeling for gaps can be optimized more or needs to
                    peel more than one iteration
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

Consider

void __attribute__((noipa)) foo(unsigned char * __restrict x,
                                unsigned char *y, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[16*i+0] = y[3*i+0];
      x[16*i+1] = y[3*i+1];
      x[16*i+2] = y[3*i+2];
      x[16*i+3] = y[3*i+0];
      x[16*i+4] = y[3*i+1];
      x[16*i+5] = y[3*i+2];
      x[16*i+6] = y[3*i+0];
      x[16*i+7] = y[3*i+1];
      x[16*i+8] = y[3*i+2];
      x[16*i+9] = y[3*i+0];
      x[16*i+10] = y[3*i+1];
      x[16*i+11] = y[3*i+2];
      x[16*i+12] = y[3*i+0];
      x[16*i+13] = y[3*i+1];
      x[16*i+14] = y[3*i+2];
      x[16*i+15] = y[3*i+0];
    }
}

and

void __attribute__((noipa)) bar(unsigned char * __restrict x,
                                unsigned char *y, int n)
{
  for (int i = 0; i < n; ++i)
    {
      x[16*i+0] = y[5*i+0];
      x[16*i+1] = y[5*i+1];
      x[16*i+2] = y[5*i+2];
      x[16*i+3] = y[5*i+3];
      x[16*i+4] = y[5*i+4];
      x[16*i+5] = y[5*i+0];
      x[16*i+6] = y[5*i+1];
      x[16*i+7] = y[5*i+2];
      x[16*i+8] = y[5*i+3];
      x[16*i+9] = y[5*i+4];
      x[16*i+10] = y[5*i+0];
      x[16*i+11] = y[5*i+1];
      x[16*i+12] = y[5*i+2];
      x[16*i+13] = y[5*i+3];
      x[16*i+14] = y[5*i+4];
      x[16*i+15] = y[5*i+0];
    }
}

for both loops we currently cannot reduce the access for the load from 'y' to
not touch extra elements so we force peeling for gaps.  But in both cases
peeling a single scalar iteration is not sufficient and we get

t.c:5:21: note:   ==> examining statement: _3 = y[_1];
t.c:5:21: missed:   peeling for gaps insufficient for access
t.c:7:20: missed:   not vectorized: relevant stmt not supported: _3 = y[_1];

we can avoid this excessive peeling for gaps if we narrow the load from 'y'
to the next power-of-two size where then it's always sufficient to just
peel a single scalar iteration.  When the target cannot construct a vector
with those elements we'd have to peel more than one iteration.

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

end of thread, other threads:[~2024-06-14 17:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-07 11:44 [Bug tree-optimization/115385] New: Peeling for gaps can be optimized more or needs to peel more than one iteration rguenth at gcc dot gnu.org
2024-06-07 11:59 ` [Bug tree-optimization/115385] " rguenth at gcc dot gnu.org
2024-06-13  6:22 ` cvs-commit at gcc dot gnu.org
2024-06-13  7:15 ` rguenth at gcc dot gnu.org
2024-06-14 16:09 ` carlos.seo at linaro dot org
2024-06-14 17:31 ` sjames at gcc dot gnu.org

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).