Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-reduc-sad-9.c

raw
1 /* Disabling epilogues until we find a better way to deal with scans. */
2 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
3 /* { dg-additional-options "-msse4.2" { target { x86_64-*-* i?86-*-* } } } */
4 /* { dg-require-effective-target vect_usad_char } */
5
6 #include <stdarg.h>
7 #include "tree-vect.h"
8
9 #define N 64
10
11 unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12 unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
13 int abs (int);
14
15 /* Sum of absolute differences between arrays of unsigned char types.
16 Detected as a sad pattern.
17 Vectorized on targets that support sad for unsigned chars. */
18
19 __attribute__ ((noinline)) int
20 foo (int len, int *res2)
21 {
22 int i;
23 int result = 0;
24 int result2 = 0;
25
26 for (i = 0; i < len; i++)
27 {
28 /* Make sure we are not using an SLP reduction for this. */
29 result += abs (X[2*i] - Y[2*i]);
30 result2 += abs (X[2*i + 1] - Y[2*i + 1]);
31 }
32
33 *res2 = result2;
34 return result;
35 }
36
37
38 int
39 main (void)
40 {
41 int i;
42 int sad;
43
44 check_vect ();
45
46 for (i = 0; i < N/2; i++)
47 {
48 X[2*i] = i;
49 Y[2*i] = N/2 - i;
50 X[2*i+1] = i;
51 Y[2*i+1] = 0;
52 __asm__ volatile ("");
53 }
54
55
56 int sad2;
57 sad = foo (N/2, &sad2);
58 if (sad != (N/2)*(N/4))
59 abort ();
60 if (sad2 != (N/2-1)*(N/2)/2)
61 abort ();
62
63 return 0;
64 }
65
66 /* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */
67 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
68