[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ctz-3.c
blob0481d0233b1d133179901890ed7ce8cd64ddeb09
1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_vsx_ok } */
4 /* { dg-options "-mdejagnu-cpu=power9 -mvsx -O2 -ftree-vectorize -fvect-cost-model=dynamic -fno-unroll-loops -fno-unroll-all-loops" } */
6 #ifndef SIZE
7 #define SIZE 1024
8 #endif
10 #ifndef ALIGN
11 #define ALIGN 32
12 #endif
14 #define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
16 #define DO_BUILTIN(PREFIX, TYPE, CTZ) \
17 TYPE PREFIX ## _a[SIZE] ALIGN_ATTR; \
18 TYPE PREFIX ## _b[SIZE] ALIGN_ATTR; \
20 void \
21 PREFIX ## _ctz (void) \
22 { \
23 unsigned long i; \
25 for (i = 0; i < SIZE; i++) \
26 PREFIX ## _a[i] = CTZ (PREFIX ## _b[i]); \
29 #if !defined(DO_LONG_LONG) && !defined(DO_LONG) && !defined(DO_INT) && !defined(DO_SHORT) && !defined(DO_CHAR)
30 #define DO_INT 1
31 #endif
33 #if DO_LONG_LONG
34 /* At the moment, only int is auto vectorized. */
35 DO_BUILTIN (sll, long long, __builtin_ctzll)
36 DO_BUILTIN (ull, unsigned long long, __builtin_ctzll)
37 #endif
39 #if defined(_ARCH_PPC64) && DO_LONG
40 DO_BUILTIN (sl, long, __builtin_ctzl)
41 DO_BUILTIN (ul, unsigned long, __builtin_ctzl)
42 #endif
44 #if DO_INT
45 DO_BUILTIN (si, int, __builtin_ctz)
46 DO_BUILTIN (ui, unsigned int, __builtin_ctz)
47 #endif
49 #if DO_SHORT
50 DO_BUILTIN (ss, short, __builtin_ctz)
51 DO_BUILTIN (us, unsigned short, __builtin_ctz)
52 #endif
54 #if DO_CHAR
55 DO_BUILTIN (sc, signed char, __builtin_ctz)
56 DO_BUILTIN (uc, unsigned char, __builtin_ctz)
57 #endif
59 /* { dg-final { scan-assembler-times "vctzw" 2 } } */
60 /* { dg-final { scan-assembler-not "cnttzd" } } */
61 /* { dg-final { scan-assembler-not "cnttzw" } } */