libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr20122.c
blob3a0387e7728fedc9872cb385dd7817f7f5cf07ac
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 short Kernshort[24] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
7 static void VecBug(short Kernel[8][24]) __attribute__((noinline));
8 static void VecBug2(short Kernel[8][24]) __attribute__((noinline));
10 /* Kernel may alias Kernshort - a global array.
11 Use versioning for aliasing. */
12 static void VecBug(short Kernel[8][24])
14 int k,i;
15 for (k = 0; k<8; k++)
16 for (i = 0; i<24; i++)
17 Kernshort[i] = Kernel[k][i];
20 /* Vectorizable: Kernshort2 is local. */
21 static void VecBug2(short Kernel[8][24])
23 int k,i;
24 short Kernshort2[24] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
25 for (k = 0; k<8; k++)
26 for (i = 0; i<24; i++)
27 Kernshort2[i] = Kernel[k][i];
29 for (k = 0; k<8; k++)
30 #pragma GCC novector
31 for (i = 0; i<24; i++)
32 if (Kernshort2[i] != Kernel[k][i])
33 abort ();
36 int main (int argc, char **argv)
38 check_vect ();
40 short Kernel[8][24];
41 int k,i;
43 for (k = 0; k<8; k++)
44 for (i = 0; i<24; i++)
46 Kernel[k][i] = 0;
47 /* Don't get into the game of versioning vs. peeling. */
48 __asm__ volatile ("" : : : "memory");
51 VecBug(Kernel);
52 VecBug2(Kernel);
54 return 0;
57 /* The loops in VecBug and VecBug2 require versioning for alignment. */
58 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
59 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */