2018-03-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / p8vector-vectorize-4.c
blob8ad8e0d6a366d2664597f0dc403b6541281dd68a
1 /* { dg-do compile { target { powerpc*-*-* } } } */
2 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
3 /* { dg-require-effective-target powerpc_p8vector_ok } */
4 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
5 /* { dg-options "-mcpu=power8 -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, CLZ, POPCNT) \
18 TYPE PREFIX ## _a[SIZE] ALIGN_ATTR; \
19 TYPE PREFIX ## _b[SIZE] ALIGN_ATTR; \
21 void \
22 PREFIX ## _clz (void) \
23 { \
24 unsigned long i; \
26 for (i = 0; i < SIZE; i++) \
27 PREFIX ## _a[i] = CLZ (PREFIX ## _b[i]); \
28 } \
30 void \
31 PREFIX ## _popcnt (void) \
32 { \
33 unsigned long i; \
35 for (i = 0; i < SIZE; i++) \
36 PREFIX ## _a[i] = POPCNT (PREFIX ## _b[i]); \
39 #if !defined(DO_LONG_LONG) && !defined(DO_LONG) && !defined(DO_INT) && !defined(DO_SHORT) && !defined(DO_CHAR)
40 #define DO_INT 1
41 #endif
43 #if DO_LONG_LONG
44 /* At the moment, only int is auto vectorized. */
45 DO_BUILTIN (sll, long long, __builtin_clzll, __builtin_popcountll)
46 DO_BUILTIN (ull, unsigned long long, __builtin_clzll, __builtin_popcountll)
47 #endif
49 #if defined(_ARCH_PPC64) && DO_LONG
50 DO_BUILTIN (sl, long, __builtin_clzl, __builtin_popcountl)
51 DO_BUILTIN (ul, unsigned long, __builtin_clzl, __builtin_popcountl)
52 #endif
54 #if DO_INT
55 DO_BUILTIN (si, int, __builtin_clz, __builtin_popcount)
56 DO_BUILTIN (ui, unsigned int, __builtin_clz, __builtin_popcount)
57 #endif
59 #if DO_SHORT
60 DO_BUILTIN (ss, short, __builtin_clz, __builtin_popcount)
61 DO_BUILTIN (us, unsigned short, __builtin_clz, __builtin_popcount)
62 #endif
64 #if DO_CHAR
65 DO_BUILTIN (sc, signed char, __builtin_clz, __builtin_popcount)
66 DO_BUILTIN (uc, unsigned char, __builtin_clz, __builtin_popcount)
67 #endif
69 /* { dg-final { scan-assembler-times "vclzw" 2 } } */
70 /* { dg-final { scan-assembler-times "vpopcntw" 2 } } */