Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / sad-vectorize-4.c
blob2db016563a5076dc001e231109aff5462b1bd02d
1 /* { dg-do run { target { powerpc*-*-linux* && { lp64 && p9vector_hw } } } } */
2 /* { dg-require-effective-target powerpc_p9vector_ok } */
3 /* { dg-options "-O3 -mcpu=power9" } */
4 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
6 /* Verify that we get correct code when we vectorize this SAD loop using
7 vabsduh. */
9 extern void abort ();
10 extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__const__));
12 static int
13 foo (unsigned short *w, int i, unsigned short *x, int j)
15 int tot = 0;
16 for (int a = 0; a < 16; a++)
18 for (int b = 0; b < 8; b++)
19 tot += abs (w[b] - x[b]);
20 w += i;
21 x += j;
23 return tot;
26 void
27 bar (unsigned short *w, unsigned short *x, int i, int *result)
29 *result = foo (w, 8, x, i);
32 int
33 main ()
35 unsigned short m[128];
36 unsigned short n[128];
37 int sum, i;
39 for (i = 0; i < 128; ++i)
40 if (i % 2 == 0)
42 m[i] = (i % 8) * 2 + 1;
43 n[i] = i % 8;
45 else
47 m[i] = (i % 8) * 4 - 3;
48 n[i] = (i % 8) >> 1;
51 bar (m, n, 8, &sum);
53 if (sum != 992)
54 abort ();
56 return 0;