[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / sad-vectorize-4.c
blobd24e2a813254d0d01257c46f362656bfe7e214f5
1 /* { dg-do run } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-O3 -mdejagnu-cpu=power9" } */
5 /* Verify that we get correct code when we vectorize this SAD loop using
6 vabsduh. */
8 extern void abort ();
9 extern int abs (int __x) __attribute__ ((__nothrow__, __leaf__)) __attribute__ ((__const__));
11 static int
12 foo (unsigned short *w, int i, unsigned short *x, int j)
14 int tot = 0;
15 for (int a = 0; a < 16; a++)
17 for (int b = 0; b < 8; b++)
18 tot += abs (w[b] - x[b]);
19 w += i;
20 x += j;
22 return tot;
25 void
26 bar (unsigned short *w, unsigned short *x, int i, int *result)
28 *result = foo (w, 8, x, i);
31 int
32 main ()
34 unsigned short m[128];
35 unsigned short n[128];
36 int sum, i;
38 for (i = 0; i < 128; ++i)
39 if (i % 2 == 0)
41 m[i] = (i % 8) * 2 + 1;
42 n[i] = i % 8;
44 else
46 m[i] = (i % 8) * 4 - 3;
47 n[i] = (i % 8) >> 1;
50 bar (m, n, 8, &sum);
52 if (sum != 992)
53 abort ();
55 return 0;