[15/n] PR85694: Try to split existing casts in widened patterns
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-15.c
blobd31050ee926ac7e12c8bce99bf3edc26a1b11fbe
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 -120
12 #endif
14 #define N 50
16 /* We rely on range analysis to show that these calculations can be done
17 in SIGNEDNESS short, with the result being extended to int for the
18 store. */
19 void __attribute__ ((noipa))
20 f (int *restrict a, SIGNEDNESS char *restrict b,
21 SIGNEDNESS char *restrict c)
23 for (int i = 0; i < N; ++i)
24 a[i] = (b[i] + c[i]) / 2;
27 int
28 main (void)
30 check_vect ();
32 int a[N];
33 SIGNEDNESS char b[N], c[N];
34 for (int i = 0; i < N; ++i)
36 b[i] = BASE_B + i * 5;
37 c[i] = BASE_C + i * 4;
38 asm volatile ("" ::: "memory");
40 f (a, b, c);
41 for (int i = 0; i < N; ++i)
42 if (a[i] != (BASE_B + BASE_C + i * 9) / 2)
43 __builtin_abort ();
45 return 0;
48 /* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */
49 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+} "vect" } } */
50 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* / 2} "vect" } } */
51 /* { dg-final { scan-tree-dump-not {vect_recog_cast_forwprop_pattern: detected} "vect" } } */
52 /* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */
53 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */