131
|
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 } */
|
|
5
|
|
6 #include "tree-vect.h"
|
|
7
|
|
8 #ifndef SIGNEDNESS
|
|
9 #define SIGNEDNESS signed
|
|
10 #define BASE_B -128
|
|
11 #define BASE_C -120
|
|
12 #endif
|
|
13
|
|
14 #define N 50
|
|
15
|
|
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)
|
|
22 {
|
|
23 for (int i = 0; i < N; ++i)
|
|
24 a[i] = (b[i] + c[i]) / 2;
|
|
25 }
|
|
26
|
|
27 int
|
|
28 main (void)
|
|
29 {
|
|
30 check_vect ();
|
|
31
|
|
32 int a[N];
|
|
33 SIGNEDNESS char b[N], c[N];
|
|
34 for (int i = 0; i < N; ++i)
|
|
35 {
|
|
36 b[i] = BASE_B + i * 5;
|
|
37 c[i] = BASE_C + i * 4;
|
|
38 asm volatile ("" ::: "memory");
|
|
39 }
|
|
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 ();
|
|
44
|
|
45 return 0;
|
|
46 }
|
|
47
|
|
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" } } */
|