libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-18.c
blobaa58cd1c95789ad4f17317c5fa501385a185edc9
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
3 /* { dg-require-effective-target vect_pack_trunc } */
4 /* { dg-require-effective-target vect_unpack } */
6 #include "tree-vect.h"
8 #define N 1024
10 /* This should be treated as an over-widening pattern: we can truncate
11 b to unsigned char after loading it and do all the computation in
12 unsigned char. */
14 void __attribute__ ((noipa))
15 f (unsigned char *restrict a, unsigned short *restrict b)
17 for (__INTPTR_TYPE__ i = 0; i < N; ++i)
19 unsigned short foo = ((b[i] & 0xef) | 0x80) + (a[i] << 4);
20 a[i] = foo;
24 int
25 main (void)
27 check_vect ();
29 unsigned char a[N];
30 unsigned short b[N];
31 for (int i = 0; i < N; ++i)
33 a[i] = i;
34 b[i] = i * 3;
35 asm volatile ("" ::: "memory");
37 f (a, b);
38 #pragma GCC novector
39 for (int i = 0; i < N; ++i)
40 if (a[i] != (unsigned char) ((((i * 3) & 0xef) | 0x80) + (i << 4)))
41 __builtin_abort ();
43 return 0;
46 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* &} "vect" } } */
47 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* |} "vect" } } */
48 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* <<} "vect" } } */
49 /* { dg-final { scan-tree-dump {vector[^\n]*char} "vect" } } */
50 /* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */
51 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */