SVE Intrinsics: Change return type of redirect_call to gcall.
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-11.c
blob1e48dab5ccb4b13c82800d890cdd5a5a5d6dd295
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, with "res"
18 being extended for the store to d[i]. */
19 void __attribute__ ((noipa))
20 f (SIGNEDNESS char *restrict a, SIGNEDNESS char *restrict b,
21 SIGNEDNESS char *restrict c, int *restrict d)
23 for (int i = 0; i < N; ++i)
25 /* Deliberate use of signed >>. */
26 int res = b[i] + c[i];
27 a[i] = (res + (res >> 1)) >> 2;
28 d[i] = res;
32 int
33 main (void)
35 check_vect ();
37 SIGNEDNESS char a[N], b[N], c[N];
38 int d[N];
39 for (int i = 0; i < N; ++i)
41 b[i] = BASE_B + i * 5;
42 c[i] = BASE_C + i * 4;
43 asm volatile ("" ::: "memory");
45 f (a, b, c, d);
46 #pragma GCC novector
47 for (int i = 0; i < N; ++i)
49 int res = BASE_B + BASE_C + i * 9;
50 if (a[i] != ((res + (res >> 1)) >> 2))
51 __builtin_abort ();
52 if (d[i] != res)
53 __builtin_abort ();
56 return 0;
59 /* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */
60 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */
61 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */
62 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */
63 /* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */
64 /* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */
65 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */