1 /* { dg-do run } */
2 /* { dg-options "-O3 -save-temps -fno-inline -fno-vect-cost-model" } */
3
4 extern void abort ();
5
6 #define TEST(name, subname, count) \
7 void \
8 count_tz_##name (unsigned *__restrict a, int *__restrict b) \
9 { \
10 int i; \
11 for (i = 0; i < count; i++) \
12 b[i] = __builtin_##subname (a[i]); \
13 }
14
15 #define CHECK(name, count, input, output) \
16 count_tz_##name (input, output); \
17 for (i = 0; i < count; i++) \
18 { \
19 if (output[i] != r[i]) \
20 abort (); \
21 }
22
23 TEST (v4si, ctz, 4)
24 TEST (v2si, ctz, 2)
25 /* { dg-final { scan-assembler "clz\tv\[0-9\]+\.4s" } } */
26 /* { dg-final { scan-assembler "clz\tv\[0-9\]+\.2s" } } */
27
28 int
main()29 main ()
30 {
31 unsigned int x4[4] = { 0x0, 0xFF80, 0x1FFFF, 0xFF000000 };
32 int r[4] = { 32, 7, 0, 24 };
33 int d[4], i;
34
35 CHECK (v4si, 4, x4, d);
36 CHECK (v2si, 2, x4, d);
37
38 return 0;
39 }
40
41