2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / ctz-3.c
blob2c1316e80e99839542e0d409eafb29ac29d24cca
1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_p9vector_ok } */
4 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
5 /* { dg-options "-mcpu=power9 -O2 -ftree-vectorize -fvect-cost-model=dynamic -fno-unroll-loops -fno-unroll-all-loops" } */
7 #ifndef SIZE
8 #define SIZE 1024
9 #endif
11 #ifndef ALIGN
12 #define ALIGN 32
13 #endif
15 #define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
17 #define DO_BUILTIN(PREFIX, TYPE, CTZ) \
18 TYPE PREFIX ## _a[SIZE] ALIGN_ATTR; \
19 TYPE PREFIX ## _b[SIZE] ALIGN_ATTR; \
21 void \
22 PREFIX ## _ctz (void) \
23 { \
24 unsigned long i; \
26 for (i = 0; i < SIZE; i++) \
27 PREFIX ## _a[i] = CTZ (PREFIX ## _b[i]); \
30 #if !defined(DO_LONG_LONG) && !defined(DO_LONG) && !defined(DO_INT) && !defined(DO_SHORT) && !defined(DO_CHAR)
31 #define DO_INT 1
32 #endif
34 #if DO_LONG_LONG
35 /* At the moment, only int is auto vectorized. */
36 DO_BUILTIN (sll, long long, __builtin_ctzll)
37 DO_BUILTIN (ull, unsigned long long, __builtin_ctzll)
38 #endif
40 #if defined(_ARCH_PPC64) && DO_LONG
41 DO_BUILTIN (sl, long, __builtin_ctzl)
42 DO_BUILTIN (ul, unsigned long, __builtin_ctzl)
43 #endif
45 #if DO_INT
46 DO_BUILTIN (si, int, __builtin_ctz)
47 DO_BUILTIN (ui, unsigned int, __builtin_ctz)
48 #endif
50 #if DO_SHORT
51 DO_BUILTIN (ss, short, __builtin_ctz)
52 DO_BUILTIN (us, unsigned short, __builtin_ctz)
53 #endif
55 #if DO_CHAR
56 DO_BUILTIN (sc, signed char, __builtin_ctz)
57 DO_BUILTIN (uc, unsigned char, __builtin_ctz)
58 #endif
60 /* { dg-final { scan-assembler-times "vctzw" 2 } } */
61 /* { dg-final { scan-assembler-not "cnttzd" } } */
62 /* { dg-final { scan-assembler-not "cnttzw" } } */