public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "changpeng dot fang at amd dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/43423] gcc should vectorize this loop through if-conversion
Date: Fri, 07 May 2010 21:41:00 -0000	[thread overview]
Message-ID: <20100507214107.23718.qmail@sourceware.org> (raw)
In-Reply-To: <bug-43423-18740@http.gcc.gnu.org/bugzilla/>



------- Comment #7 from changpeng dot fang at amd dot com  2010-05-07 21:41 -------
(In reply to comment #4)
> (In reply to comment #3)
> > Subject: Re:  gcc should vectorize this loop 
> >         through "iteration range splitting"
> > You mean that the problem is the if-conversion of the stores
> > "a[i] = ..."
> 
> If we rewrite the code like:
> int a[100], b[100], c[100];
> 
> void foo(int n, int mid)
> {
>   int i;
>   for(i=0; i<n; i++)
>     {
>       int t;
>       int ai = a[i], bi = b[i], ci = c[i];
>       if (i < mid)
>         t = ai + bi;
>       else
>         t = ai + ci;
>       a[i] = t;
>     }
> }
> 
> --- CUT ---
> This gets vectorized as we produce an if-cvt first.
> 

There are both correctness and performance issues in the re-written code.
b[i] or c[i] may not be executed in the original loop.


-- 


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


  parent reply	other threads:[~2010-05-07 21:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18 18:01 [Bug c/43423] New: gcc should vectorize this loop through "iteration range splitting" changpeng dot fang at amd dot com
2010-03-18 18:13 ` [Bug c/43423] " amonakov at gcc dot gnu dot org
2010-03-18 18:22 ` [Bug tree-optimization/43423] " pinskia at gcc dot gnu dot org
2010-03-18 18:33   ` Sebastian Pop
2010-03-18 18:33 ` sebpop at gmail dot com
2010-03-18 18:38 ` pinskia at gcc dot gnu dot org
2010-03-18 18:51 ` spop at gcc dot gnu dot org
2010-04-08 17:47 ` [Bug tree-optimization/43423] gcc should vectorize this loop through if-conversion spop at gcc dot gnu dot org
2010-05-07 21:41 ` changpeng dot fang at amd dot com [this message]
2010-05-24 22:44 ` spop at gcc dot gnu dot org
2010-05-24 22:47 ` changpeng dot fang at amd dot com
2010-05-24 23:02 ` spop at gcc dot gnu dot org
2010-05-25 23:33 ` spop at gcc dot gnu dot org
     [not found] <bug-43423-4@http.gcc.gnu.org/bugzilla/>
2021-07-20  2:47 ` pinskia at gcc dot gnu.org
2021-09-14  6:34 ` pinskia 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=20100507214107.23718.qmail@sourceware.org \
    --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).