public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56541] New: vectorizaton fails in conditional assignment of a constant
@ 2013-03-05 16:44 vincenzo.innocente at cern dot ch
  2013-03-06  9:13 ` [Bug tree-optimization/56541] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2013-03-05 16:44 UTC (permalink / raw)
  To: gcc-bugs


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.


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

* [Bug tree-optimization/56541] vectorizaton fails in conditional assignment of a constant
  2013-03-05 16:44 [Bug tree-optimization/56541] New: vectorizaton fails in conditional assignment of a constant vincenzo.innocente at cern dot ch
@ 2013-03-06  9:13 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-06  9:13 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-03-06
             Blocks|                            |53947
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-06 09:13:29 UTC ---
if-conversion is confused by the three-argument PHI node:

  <bb 6>:
  # rMin_3 = PHI <rMin_11(5), rMin_12(4), 1.5e+2(3)>

that occurs because of the forwarder block (which isn't one in the
case the addition appears).  DOM produces this by threading

  if (rMin_12 > 0.0)
    goto <bb 4>;
  else
    goto <bb 5>;

  <bb 4>:

  <bb 5>:
  # rMin_2 = PHI <rMin_11(4), 1.5e+2(3)>
  if (rMin_2 > 0.0)
    goto <bb 7>;
  else
    goto <bb 6>;
...
  <bb 7>:
  # rMin_3 = PHI <rMin_2(5), rMin_12(6)>

for rMin_2 == 1.5e+2.  That's a good optimization.


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

* [Bug tree-optimization/56541] vectorizaton fails in conditional assignment of a constant
  2013-03-05 16:44 [Bug tree-optimization/56541] New: vectorizaton fails in conditional assignment of a constant vincenzo.innocente at cern dot ch
  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
  2 siblings, 0 replies; 4+ messages in thread
From: alalaw01 at gcc dot gnu.org @ 2015-06-11 15:30 UTC (permalink / raw)
  To: gcc-bugs

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

alalaw01 at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alalaw01 at gcc dot gnu.org

--- Comment #2 from alalaw01 at gcc dot gnu.org ---
If-conversion will handle the three-arg phi node, if aggressive_if_conv is
true, i.e. if loop->force_vectorize. I believe it's possible to set this using
a #pragma (?), but I haven't managed yet. A question might be whether it's safe
to deal with three-arg phi-nodes when !aggressive_if_conv...


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

* [Bug tree-optimization/56541] vectorizaton fails in conditional assignment of a constant
  2013-03-05 16:44 [Bug tree-optimization/56541] New: vectorizaton fails in conditional assignment of a constant vincenzo.innocente at cern dot ch
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-12 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |7.0

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

end of thread, other threads:[~2021-12-12 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-05 16:44 [Bug tree-optimization/56541] New: vectorizaton fails in conditional assignment of a constant vincenzo.innocente at cern dot ch
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

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).