public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/58821] New: conditional reduction does not vectorize
Date: Mon, 21 Oct 2013 07:44:00 -0000	[thread overview]
Message-ID: <bug-58821-4@http.gcc.gnu.org/bugzilla/> (raw)

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;
}


             reply	other threads:[~2013-10-21  7:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21  7:44 vincenzo.innocente at cern dot ch [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58821-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).