comparison gcc/testsuite/gcc.dg/vect/vect-avg-16.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* { dg-additional-options "-O3" } */
2 /* { dg-require-effective-target vect_int } */
3
4 #include "tree-vect.h"
5
6 #define N 80
7
8 void __attribute__ ((noipa))
9 f (signed char *restrict a, signed char *restrict b,
10 signed char *restrict c, int n)
11 {
12 for (int j = 0; j < n; ++j)
13 {
14 for (int i = 0; i < 16; ++i)
15 a[i] = (b[i] + c[i]) >> 1;
16 a += 20;
17 b += 20;
18 c += 20;
19 }
20 }
21
22 #define BASE1 -126
23 #define BASE2 -42
24
25 signed char a[N], b[N], c[N];
26
27 int
28 main (void)
29 {
30 check_vect ();
31
32 for (int i = 0; i < N; ++i)
33 {
34 a[i] = i;
35 b[i] = BASE1 + i * 3;
36 c[i] = BASE2 + i * 2;
37 asm volatile ("" ::: "memory");
38 }
39 f (a, b, c, N / 20);
40 for (int i = 0; i < N; ++i)
41 {
42 int d = (BASE1 + BASE2 + i * 5) >> 1;
43 if (a[i] != (i % 20 < 16 ? d : i))
44 __builtin_abort ();
45 }
46 return 0;
47 }
48
49 /* { dg-final { scan-tree-dump "vect_recog_average_pattern: detected" "vect" } } */
50 /* { dg-final { scan-tree-dump {\.AVG_FLOOR} "vect" { target vect_avg_qi } } } */
51 /* { dg-final { scan-tree-dump "Loop contains only SLP stmts" "vect" { target vect_avg_qi } } } */
52 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" { target vect_avg_qi } } } */