public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-21462-7559@http.gcc.gnu.org/bugzilla/>]
* [Bug tree-optimization/21462] New: if statement not converted to MIN_EXPR
@ 2005-05-09  8:01 micis at gmx dot de
  2005-05-09 21:33 ` [Bug tree-optimization/21462] " pinskia at gcc dot gnu dot org
  2005-05-09 21:34 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 4+ messages in thread
From: micis at gmx dot de @ 2005-05-09  8:01 UTC (permalink / raw)
  To: gcc-bugs

Consider the following short program:

#include <algorithm>

void Tst1(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
    for (int x=0; x<Len; x++)
        MinP[x] = SrcP[x] <? MinP[x];
}

void Tst2(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
    for (int x=0; x<Len; x++)
        MinP[x] = (SrcP[x]<MinP[x]) ? SrcP[x] : MinP[x];
}

void Tst3(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
    for (int x=0; x<Len; x++)
        MinP[x] = (SrcP[x]<MinP[x]) ? (short)SrcP[x] : MinP[x];
}

void Tst4(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
    for (int x=0; x<Len; x++)
        MinP[x] = std::min(SrcP[x], MinP[x]);
}

void Tst5(short* __restrict__ SrcP, short* __restrict__ MinP, int Len)
{
    for (int x=0; x<Len; x++)
        if (SrcP[x]<MinP[x])  MinP[x]=SrcP[x];
}

If I compile it with
    gcc41 -O2 -ftree-vectorize -ftree-vectorizer-verbose=5
function Tst1/Tst2/Tst3 gets vectorized but Tst4/Tst5 not.

The reason for this is the first three funtions result in a MIN_EXPR while 
std::min and the if statement generate conditional code which the vectorizer 
does not recognize.


Michael Cieslinski

-- 
           Summary: if statement not converted to MIN_EXPR
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: micis at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

end of thread, other threads:[~2012-02-07 21:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-21462-4@http.gcc.gnu.org/bugzilla/>
2012-02-07 21:07 ` [Bug tree-optimization/21462] if statement not converted to MIN_EXPR pinskia at gcc dot gnu.org
     [not found] <bug-21462-7559@http.gcc.gnu.org/bugzilla/>
2007-04-18  9:00 ` rguenth at gcc dot gnu dot org
2005-05-09  8:01 [Bug tree-optimization/21462] New: " micis at gmx dot de
2005-05-09 21:33 ` [Bug tree-optimization/21462] " pinskia at gcc dot gnu dot org
2005-05-09 21:34 ` pinskia at gcc dot gnu dot 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).