| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target arm_neon_ok } */ |
| 3 |
/* { dg-add-options arm_neon } */ |
| 4 |
/* { dg-additional-options "-O3" } */ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
/* Since we have implemented the avg* optabs for 128-bit vectors only, use |
| 9 |
enough iterations to check that vectorization works as expected. */ |
| 10 |
|
| 11 |
/* We force a cast to int64_t to enable the vectorizer when dealing with 32-bit |
| 12 |
inputs. */ |
| 13 |
#define FUNC(SIGN, TYPE, BITS, OP, NAME) \ |
| 14 |
void test_ ## NAME ##_ ## SIGN ## BITS (TYPE##BITS##_t * __restrict__ dest, \ |
| 15 |
TYPE##BITS##_t *a, TYPE##BITS##_t *b) { \ |
| 16 |
int i; \ |
| 17 |
for (i=0; i < (128 / BITS); i++) { \ |
| 18 |
dest[i] = ((int64_t)a[i] OP b[i]) >> 1; \ |
| 19 |
} \ |
| 20 |
} |
| 21 |
|
| 22 |
FUNC(s, int, 32, +, vhadd) |
| 23 |
FUNC(u, uint, 32, +, vhadd) |
| 24 |
FUNC(s, int, 16, +, vhadd) |
| 25 |
FUNC(u, uint, 16, +, vhadd) |
| 26 |
FUNC(s, int, 8, +, vhadd) |
| 27 |
FUNC(u, uint, 8, +, vhadd) |
| 28 |
|
| 29 |
/* { dg-final { scan-assembler-times {vhadd\.s32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |
| 30 |
/* { dg-final { scan-assembler-times {vhadd\.u32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |
| 31 |
/* { dg-final { scan-assembler-times {vhadd\.s16\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |
| 32 |
/* { dg-final { scan-assembler-times {vhadd\.u16\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |
| 33 |
/* { dg-final { scan-assembler-times {vhadd\.s8\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |
| 34 |
/* { dg-final { scan-assembler-times {vhadd\.u8\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ |