public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/50596] Problems in vectorization of condition expression
Date: Tue, 04 Oct 2011 07:05:00 -0000	[thread overview]
Message-ID: <bug-50596-4-oSwCwc8c2l@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50596-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irar at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-10-04 07:04:25 UTC ---
The first problem with vectorization of ori function is similar to why the
first loop below is not vectorized and second is:
float a[1024], b[1024], c[1024], d[1024], e[1024];
void foo (void)
{
  for (int i = 0; i < 1024; i++)
    a[i] = b[i] < c[i] ? d[i] : e[i];
}
void bar (void)
{
  for (int i = 0; i < 1024; i++)
    {
      float d_ = d[i], e_ = e[i];
      a[i] = b[i] < c[i] ? d_ : e_;
    }
}

gcc doesn't think it is ok to load d[i] resp. e[i] unconditionally.  In this
exact case where the loop bound is known and it is an static array of at least
that size it is probably fine, but if d or e was a pointer which might point to
a smaller array, d[i] or e[i] accesses might segfault.

That said, we still have control flow that even ifcvt doesn't fix up even with:
void
f2 ()
{
  for (int i = 0; i != N; ++i)
    {
      float c_ = c[i], d_ = d[i];
      z[i] = a[i] < b[i] && c_ < d_;
    }
}

void
f3 ()
{
  for (int i = 0; i != N; ++i)
    {
      float a_ = a[i], b_ = b[i], c_ = c[i], d_ = d[i];
      z[i] = a_ < b_ && c_ < d_;
    }
}

Note even if there would be no control flow, we'd still give up on bool not
being vectorized.  Bool is problematic, we'd have to use an unsigned char
vector instead (if bool is QImode) for vcond.  But it would be a vcond with
different
datamode and cmpmode size, we'd either need to do it using a V4SFmode/V8SFmode
vcond, then VEC_PACK_TRUNC_EXPR them into V16QImode/V32QImode.

Anyway, I think handling _Bool/bool somehow is now much more urgent than it has
been before, given Kai's/Richard's change to use _Bool/bool much more often in
GIMPLE.  If a bool SSA_NAME just feeds some COND_EXPR, we could just use some
wider type, or we could use wider vcond etc.


  parent reply	other threads:[~2011-10-04  7:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03  8:08 [Bug tree-optimization/50596] New: " vincenzo.innocente at cern dot ch
2011-10-03  8:41 ` [Bug tree-optimization/50596] " vincenzo.innocente at cern dot ch
2011-10-04  7:05 ` jakub at gcc dot gnu.org [this message]
2011-10-04  9:12 ` vincenzo.innocente at cern dot ch
2011-10-04 11:10 ` rguenth at gcc dot gnu.org
2011-10-04 11:14 ` jakub at gcc dot gnu.org
2011-10-04 11:28 ` rguenther at suse dot de
2011-10-04 11:29 ` rguenther at suse dot de
2011-10-05  7:11 ` jakub at gcc dot gnu.org
2011-10-06 11:58 ` jakub at gcc dot gnu.org
2011-10-06 12:31 ` irar at il dot ibm.com
2011-10-06 13:34 ` jakub at gcc dot gnu.org
2011-10-06 17:51 ` jakub at gcc dot gnu.org
2011-10-07  7:36 ` vincenzo.innocente at cern dot ch
2011-10-07 10:16 ` vincenzo.innocente at cern dot ch
2011-10-07 10:31 ` jakub at gcc dot gnu.org
2011-10-16 13:11 ` jakub at gcc dot gnu.org
2011-10-16 13:47 ` vincenzo.innocente at cern dot ch
2011-10-25  8:03 ` jakub at gcc dot gnu.org
2011-10-25  8:24 ` jakub 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-50596-4-oSwCwc8c2l@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).