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/56541] New: vectorizaton fails in conditional assignment of a constant
Date: Tue, 05 Mar 2013 16:44:00 -0000	[thread overview]
Message-ID: <bug-56541-4@http.gcc.gnu.org/bugzilla/> (raw)


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

             Bug #: 56541
           Summary: vectorizaton fails in conditional assignment of a
                    constant
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincenzo.innocente@cern.ch


this loop does not vectorize

#include<cmath>
float a,b,c,d;

float z[1024]; bool ok[1024];
constexpr float rBig = 150.;

void foo() {
  for (int i=0;i!=1024;++i) {
    float rR = a*z[i];
    float rL = b*z[i];
    float rMin = (rR<rL) ? rR : rL;  
    float rMax = (rR<rL) ? rL : rR;  
    //rMin = (rMax>0) ? rMin : rBig+std::abs(z[i]); // this vectorize (sic...)
    rMin = (rMax>0) ? rMin : rBig; // comment to vectorize
    rMin = (rMin>0) ? rMin : rMax; 
    ok[i] = rMin-c<rMax+d;
  }

}

c++ -std=c++11 -Ofast -march=corei7 -c range.cc -ftree-vectorizer-verbose=1

Analyzing loop at range.cc:8
range.cc:7: note: vectorized 0 loops in function.
range.cc:16: note: vect_recog_bool_pattern: detected: 
range.cc:16: note: pattern recognized: VIEW_CONVERT_EXPR<unsigned
char>(ok[i_22]) = patt_15;
range.cc:16: note: additional pattern stmt: patt_13 = _14 < _16 ? 1 : 0;

adding to "rBig" std::abs(z[i]) it does
c++ -std=c++11 -Ofast -march=corei7 -c range.cc -ftree-vectorizer-verbose=1

Analyzing loop at range.cc:8

range.cc:8: note: vect_recog_bool_pattern: detected: 
range.cc:8: note: pattern recognized: VIEW_CONVERT_EXPR<unsigned
char>(ok[i_24]) = patt_16;

range.cc:8: note: additional pattern stmt: patt_14 = _15 < _17 ? 1 : 0;


Vectorizing loop at range.cc:8

range.cc:8: note: LOOP VECTORIZED.
range.cc:7: note: vectorized 1 loops in function.


             reply	other threads:[~2013-03-05 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-05 16:44 vincenzo.innocente at cern dot ch [this message]
2013-03-06  9:13 ` [Bug tree-optimization/56541] " rguenth at gcc dot gnu.org
2015-06-11 15:30 ` alalaw01 at gcc dot gnu.org
2021-12-12 10:50 ` pinskia 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-56541-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).