public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58821] New: conditional reduction does not vectorize
@ 2013-10-21  7:44 vincenzo.innocente at cern dot ch
  2013-10-21  8:23 ` [Bug tree-optimization/58821] " rguenth at gcc dot gnu.org
  2021-06-08 14:01 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2013-10-21  7:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58821
           Summary: conditional reduction does not vectorize
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch

in the following foo vectorize bar does not
(bar does not vectorize even for 
 if (x[i]>0) s+=x[i];
)
compiled as 
c++ -Ofast -fopt-info-loop -S condRed.cc -fopenmp -ftree-loop-if-convert-stores
-march=core-avx2

gcc version 4.9.0 20131011 (experimental) [trunk revision 203426] (GCC) 

neither
#pragma omp simd reduction(+:s)
nor
#pragma ivdep
helps


const int N=1024;
float x[N], y[N];

float bar() {
  float s=0;
  for (int i=0; i<N; ++i)
   if (x[i]>0) s+=y[i];
  return s;
}


float foo() {
  float s=0;
  for (int i=0; i<N; ++i)
   s+= (x[i]>0) ?y[i] : 0;
  return s;
}



float barOMP() {
  float s=0;
#pragma omp simd reduction(+:s)
  for (int i=0; i<N; ++i)
   if (x[i]>0) s+=y[i];
  return s;
}


float fooOMP() {
  float s=0;
#pragma omp simd reduction(+:s)
  for (int i=0; i<N; ++i)
   s+= (x[i]>0) ?y[i] : 0;
  return s;
}


float barIVDEP() {
  float s=0;
#pragma ivdep
  for (int i=0; i<N; ++i)
   if (x[i]>0) s+=y[i];
  return s;
}


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

end of thread, other threads:[~2021-06-08 14:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-21  7:44 [Bug tree-optimization/58821] New: conditional reduction does not vectorize vincenzo.innocente at cern dot ch
2013-10-21  8:23 ` [Bug tree-optimization/58821] " rguenth at gcc dot gnu.org
2021-06-08 14:01 ` rguenth 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).