public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "micis at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/21462] New: if statement not converted to MIN_EXPR
Date: Mon, 09 May 2005 08:01:00 -0000	[thread overview]
Message-ID: <20050509080125.21462.micis@gmx.de> (raw)

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


             reply	other threads:[~2005-05-09  8:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-09  8:01 micis at gmx dot de [this message]
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

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=20050509080125.21462.micis@gmx.de \
    --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).