fortran/trans-openmp.cc: Use the correct member in gfc_omp_namelist [PR118745]
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-sad-9.c
blob3c6af4510f451e3700f715d07c931a771d4c05ff
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 } */
6 #include <stdarg.h>
7 #include "tree-vect.h"
9 #define N 64
11 unsigned char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
12 unsigned char Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
13 int abs (int);
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. */
19 __attribute__ ((noinline)) int
20 foo (int len, int *res2)
22 int i;
23 int result = 0;
24 int result2 = 0;
26 for (i = 0; i < len; i++)
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]);
33 *res2 = result2;
34 return result;
38 int
39 main (void)
41 int i;
42 int sad;
44 check_vect ();
46 for (i = 0; i < N/2; i++)
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 ("");
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 ();
63 return 0;
66 /* { dg-final { scan-tree-dump "vect_recog_sad_pattern: detected" "vect" } } */
67 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */