public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/49730] New: loop not vectorized if inside another loop
@ 2011-07-13 10:43 vincenzo.innocente at cern dot ch
  2011-07-13 11:24 ` [Bug tree-optimization/49730] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-07-13 10:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49730

           Summary: loop not vectorized if inside another loop
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincenzo.innocente@cern.ch


I've this simple double loop (used in benchmark)
the inner loop (sloop) is not vectorized when invoked inside the longer loop
(dloop)

 c++ -Ofast -c vectdloop.cc -ftree-vectorizer-verbose=7
vectdloop.cc:9: note:   Profitability threshold = 6

vectdloop.cc:9: note: Profitability threshold is 6 loop iterations.
vectdloop.cc:9: note: LOOP VECTORIZED.
vectdloop.cc:7: note: vectorized 1 loops in function.

vectdloop.cc:20: note: not vectorized: unexpected loop form.
vectdloop.cc:16: note: vectorized 0 loops in function.


#include<cmath>

inline float fn(float x) {
  return 2.f*x+std::sqrt(x);
}

void sloop(float * __restrict__ s, float const * __restrict__ xx) {
  const int ls=16;
  for (int j=0; j < ls; ++j) {
    s[j] = fn(xx[j]);
  } 
}

int dloop(float yyy) {
  int niter = 100000;
  float x = 0.5f; yyy=0;
  const int ls=16;
  for (int i=0; i < niter; ++i) { 
    float s[ls]; float xx[ls];
    for (int j=0; j < ls; ++j) xx[j] =x+(5*(j&1));
    sloop(s,xx);
    // for (int j=0; j < ls; ++j)  s[j] = fn(xx[j]); 
    x += 1e-6f;
    for (int j=0; j < ls; ++j) yyy+=s[j];
  }
  if (yyy == 2.32132323232f) niter--; 
  return niter;
}


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

* [Bug tree-optimization/49730] loop not vectorized if inside another loop
  2011-07-13 10:43 [Bug tree-optimization/49730] New: loop not vectorized if inside another loop vincenzo.innocente at cern dot ch
@ 2011-07-13 11:24 ` rguenth at gcc dot gnu.org
  2011-07-14  6:35 ` irar at il dot ibm.com
  2021-12-04 23:58 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-13 11:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49730

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2011.07.13 11:23:16
                 CC|                            |irar at gcc dot gnu.org
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-13 11:23:16 UTC ---
All inner loops are simply completely unrolled which eliminates the s array.

Then we end up with a loop with two reductions which cannot be vectorized
right now.


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

* [Bug tree-optimization/49730] loop not vectorized if inside another loop
  2011-07-13 10:43 [Bug tree-optimization/49730] New: loop not vectorized if inside another loop vincenzo.innocente at cern dot ch
  2011-07-13 11:24 ` [Bug tree-optimization/49730] " rguenth at gcc dot gnu.org
@ 2011-07-14  6:35 ` irar at il dot ibm.com
  2021-12-04 23:58 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: irar at il dot ibm.com @ 2011-07-14  6:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49730

Ira Rosen <irar at il dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irar at il dot ibm.com

--- Comment #2 from Ira Rosen <irar at il dot ibm.com> 2011-07-14 06:35:39 UTC ---
There is no limitation on the number of reductions in vectorization.

The problem here is a non-empty latch block. There are several existing PRs for
similar problems: pr 33447, pr 28643.

Ira


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

* [Bug tree-optimization/49730] loop not vectorized if inside another loop
  2011-07-13 10:43 [Bug tree-optimization/49730] New: loop not vectorized if inside another loop vincenzo.innocente at cern dot ch
  2011-07-13 11:24 ` [Bug tree-optimization/49730] " rguenth at gcc dot gnu.org
  2011-07-14  6:35 ` irar at il dot ibm.com
@ 2021-12-04 23:58 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-04 23:58 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |8.0
         Resolution|---                         |FIXED
      Known to work|                            |8.1.0, 9.1.0
             Status|NEW                         |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 8.

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

end of thread, other threads:[~2021-12-04 23:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 10:43 [Bug tree-optimization/49730] New: loop not vectorized if inside another loop vincenzo.innocente at cern dot ch
2011-07-13 11:24 ` [Bug tree-optimization/49730] " rguenth at gcc dot gnu.org
2011-07-14  6:35 ` irar at il dot ibm.com
2021-12-04 23:58 ` pinskia 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).