| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
/* This function should produce cnt v.16b. */ |
| 5 |
void |
| 6 |
bar (unsigned char *__restrict b, unsigned char *__restrict d) |
| 7 |
{ |
| 8 |
for (int i = 0; i < 1024; i++) |
| 9 |
d[i] = __builtin_popcount (b[i]); |
| 10 |
} |
| 11 |
|
| 12 |
/* This function should produce cnt v.16b and uaddlp (Add Long Pairwise). */ |
| 13 |
void |
| 14 |
bar1 (unsigned short *__restrict b, unsigned short *__restrict d) |
| 15 |
{ |
| 16 |
for (int i = 0; i < 1024; i++) |
| 17 |
d[i] = __builtin_popcount (b[i]); |
| 18 |
} |
| 19 |
|
| 20 |
/* This function should produce cnt v.16b and 2 uaddlp (Add Long Pairwise). */ |
| 21 |
void |
| 22 |
bar2 (unsigned int *__restrict b, unsigned int *__restrict d) |
| 23 |
{ |
| 24 |
for (int i = 0; i < 1024; i++) |
| 25 |
d[i] = __builtin_popcount (b[i]); |
| 26 |
} |
| 27 |
|
| 28 |
/* This function should produce cnt v.16b and 3 uaddlp (Add Long Pairwise). */ |
| 29 |
void |
| 30 |
bar3 (unsigned long long *__restrict b, unsigned long long *__restrict d) |
| 31 |
{ |
| 32 |
for (int i = 0; i < 1024; i++) |
| 33 |
d[i] = __builtin_popcountll (b[i]); |
| 34 |
} |
| 35 |
|
| 36 |
/* SLP |
| 37 |
This function should produce cnt v.8b and uaddlp (Add Long Pairwise). */ |
| 38 |
void |
| 39 |
bar4 (unsigned short *__restrict b, unsigned short *__restrict d) |
| 40 |
{ |
| 41 |
d[0] = __builtin_popcount (b[0]); |
| 42 |
d[1] = __builtin_popcount (b[1]); |
| 43 |
d[2] = __builtin_popcount (b[2]); |
| 44 |
d[3] = __builtin_popcount (b[3]); |
| 45 |
} |
| 46 |
|
| 47 |
/* SLP |
| 48 |
This function should produce cnt v.8b and 2 uaddlp (Add Long Pairwise). */ |
| 49 |
void |
| 50 |
bar5 (unsigned int *__restrict b, unsigned int *__restrict d) |
| 51 |
{ |
| 52 |
d[0] = __builtin_popcount (b[0]); |
| 53 |
d[1] = __builtin_popcount (b[1]); |
| 54 |
} |
| 55 |
|
| 56 |
/* SLP |
| 57 |
This function should produce cnt v.16b and 3 uaddlp (Add Long Pairwise). */ |
| 58 |
void |
| 59 |
bar6 (unsigned long long *__restrict b, unsigned long long *__restrict d) |
| 60 |
{ |
| 61 |
d[0] = __builtin_popcountll (b[0]); |
| 62 |
d[1] = __builtin_popcountll (b[1]); |
| 63 |
} |
| 64 |
|
| 65 |
/* { dg-final { scan-assembler-not {\tbl\tpopcount} } } */ |
| 66 |
/* { dg-final { scan-assembler-times {cnt\t} 7 } } */ |
| 67 |
/* { dg-final { scan-assembler-times {uaddlp\t} 12 } } */ |
| 68 |
/* { dg-final { scan-assembler-times {ldr\tq} 5 } } */ |
| 69 |
/* { dg-final { scan-assembler-times {ldr\td} 2 } } */ |