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