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: unassig...@gcc.gnu.org

        ReportedBy: vincenzo.innoce...@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 via email to