[AArch64] Add support for SVE CLS and CLZ
[gcc.git] / gcc / testsuite / gcc.target / aarch64 / sve / clz_1_run.c
1 /* { dg-do run { target aarch64_sve_hw } } */
2 /* { dg-options "-O2 -ftree-vectorize" } */
3
4 #include "clz_1.c"
5
6 extern void abort (void) __attribute__ ((noreturn));
7
8 unsigned int data[] = {
9 0xffffff80, 0,
10 0xffffffff, 0,
11 0x00000000, 32,
12 0x80000000, 0,
13 0x7fffffff, 1,
14 0x000003ff, 22,
15 0x1fffffff, 3,
16 0x0000ffff, 16,
17 0xffff0000, 0
18 };
19
20 int __attribute__ ((optimize (1)))
21 main (void)
22 {
23 unsigned int count = sizeof (data) / sizeof (data[0]) / 2;
24
25 uint32_t in32[count];
26 unsigned int out32[count];
27 for (unsigned int i = 0; i < count; ++i)
28 {
29 in32[i] = data[i * 2];
30 asm volatile ("" ::: "memory");
31 }
32 clz_32 (out32, in32, count);
33 for (unsigned int i = 0; i < count; ++i)
34 if (out32[i] != data[i * 2 + 1])
35 abort ();
36
37 uint64_t in64[count];
38 unsigned int out64[count];
39 for (unsigned int i = 0; i < count; ++i)
40 {
41 in64[i] = (uint64_t) data[i * 2] << 10;
42 asm volatile ("" ::: "memory");
43 }
44 clz_64 (out64, in64, count);
45 for (unsigned int i = 0; i < count; ++i)
46 if (out64[i] != (data[i * 2] ? data[i * 2 + 1] + 22 : 64))
47 abort ();
48
49 return 0;
50 }