PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-5.c
blob269df5387d20c859806da03aed91d77955fa651a
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 #ifndef SIGNEDNESS
9 #define SIGNEDNESS signed
10 #define BASE_B -128
11 #define BASE_C -100
12 #endif
14 #define N 50
16 /* Both range analysis and backward propagation from the truncation show
17 that these calculations can be done in SIGNEDNESS short. */
18 void __attribute__ ((noipa))
19 f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b,
20 SIGNEDNESS char *restrict c)
22 /* Deliberate use of signed >>. */
23 for (int i = 0; i < N; ++i)
24 a[i] = (b[i] + c[i]) >> 1;
27 int
28 main (void)
30 check_vect ();
32 SIGNEDNESS char a[N], b[N], c[N];
33 for (int i = 0; i < N; ++i)
35 b[i] = BASE_B + i * 5;
36 c[i] = BASE_C + i * 4;
37 asm volatile ("" ::: "memory");
39 f (a, b, c);
40 for (int i = 0; i < N; ++i)
41 if (a[i] != (BASE_B + BASE_C + i * 9) >> 1)
42 __builtin_abort ();
44 return 0;
47 /* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */
48 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */
49 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */
50 /* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */
51 /* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */
52 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */