This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about vectorization


On Thu, Jan 15, 2015 at 2:22 PM, Konstantin Vladimirov
<konstantin.vladimirov@gmail.com> wrote:
> Hi,
>
> Consider simple test:
>
> #include <stdlib.h>
>
> #ifdef FAILV
>
> unsigned short* get_aa(void);
> double* get_bb(void);
>
> #else
>
> extern unsigned short a[1024];
> extern double b[1024];
>
> #endif
>
>
> unsigned short *foo()
> {
>     size_t i;
>
> #ifdef FAILV
>     unsigned short * restrict aa = get_aa();
>     double * restrict bb = get_bb();
> #else
>     unsigned short * restrict aa = a;
>     double * restrict bb = b;
> #endif
>
>     for (i = 0; i < 1024; ++i)
>     {
>         *bb = *aa;
>         ++bb; ++aa;
>     }
>
>     return aa;
> }
>
> Compile it with latest gcc, 4.8 or 4.9:
>
> gcc -O3 -ftree-vectorizer-verbose=2 --std=c99 -S test.c
> gcc -O3 -ftree-vectorizer-verbose=2 --std=c99 -S test.c -DFAILV
>
> In second case it outputs:
>
> test.c:28: note: versioning for alias required: can't determine
> dependence between *aa_22 and *bb_23
>
> So loop is vectorized but there is unnecessary aliasing check inside.
>
> But AFAIC, due to strong aliasing rules, compiler should statically
> know, that aliasing is not possible in that case.

It can know but only because it is in a loop.  I belive this is fixed
already for GCC 5.

Richard.



> Is it a bug?
>
> ---
> With best regards, Konstantin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]