public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101842] New: Vectorizer doesn't vectorize when loop bound depends on two independent variables that are unknown
@ 2021-08-10  9:41 tnfchris at gcc dot gnu.org
  2021-08-10 10:06 ` [Bug tree-optimization/101842] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tnfchris at gcc dot gnu.org @ 2021-08-10  9:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101842
           Summary: Vectorizer doesn't vectorize when loop bound depends
                    on two independent variables that are unknown
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
  Target Milestone: ---

The following example

float f(float *p, float d, int len, float lim)
{
  float m[4];
  for (int i = 0; i < len && d >= lim; i += 4)
  {
    m[0] = p[0] * p[0];
    m[1] = p[1] * p[1];
    m[2] = p[2] * p[2];
    m[3] = p[3] * p[3];
    d = d - m[0];
    d = d - m[1];
    d = d - m[2];
    d = d - m[3];
    p += 4;
  }

  return d;
}

isn't vectorized at -Ofast because

```
missed: not vectorized: number of iterations cannot be computed.
```

which seems odd because I would expect that it would be treated as just any
other loop with unbounded iterations.  Commenting out this check results in it
bailing out because of it not knowing how to deal with the reduction.

This loop should be easy to vectorize with vectorizing the multiplications of m
and then reducing the changes of `d - sum (m[0..3])`.

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

end of thread, other threads:[~2021-08-10 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10  9:41 [Bug tree-optimization/101842] New: Vectorizer doesn't vectorize when loop bound depends on two independent variables that are unknown tnfchris at gcc dot gnu.org
2021-08-10 10:06 ` [Bug tree-optimization/101842] " rguenth at gcc dot gnu.org
2021-08-10 10:22 ` rguenth at gcc dot gnu.org
2021-08-10 10:44 ` tnfchris at gcc dot gnu.org
2021-08-10 10:54 ` rguenth at gcc dot gnu.org
2021-08-10 11:16 ` tnfchris 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).