| 1 |
/* { dg-do assemble } */ |
| 2 |
/* { dg-require-effective-target arm_v8_1m_mve_fp_ok } */ |
| 3 |
/* { dg-add-options arm_v8_1m_mve_fp } */ |
| 4 |
/* { dg-additional-options "-O3 -funsafe-math-optimizations -fdump-tree-optimized" } */ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
#include <arm_mve.h> |
| 8 |
|
| 9 |
#define ABS(a) ((a < 0) ? -a : a) |
| 10 |
|
| 11 |
#define FUNC(SIGN, TYPE, BITS, NB, NAME) \ |
| 12 |
void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, TYPE##BITS##_t *a) { \ |
| 13 |
int i; \ |
| 14 |
for (i=0; i<NB; i++) { \ |
| 15 |
dest[i] = ABS(a[i]); \ |
| 16 |
} \ |
| 17 |
} |
| 18 |
|
| 19 |
#define FUNC_FLOAT(SIGN, TYPE, BITS, NB, NAME) \ |
| 20 |
void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE * __restrict__ dest, TYPE *a) { \ |
| 21 |
int i; \ |
| 22 |
for (i=0; i<NB; i++) { \ |
| 23 |
dest[i] = ABS(a[i]); \ |
| 24 |
} \ |
| 25 |
} |
| 26 |
|
| 27 |
/* 128-bit vectors. */ |
| 28 |
FUNC(s, int, 32, 4, vabs) |
| 29 |
FUNC(u, uint, 32, 4, vabs) |
| 30 |
FUNC(s, int, 16, 8, vabs) |
| 31 |
FUNC(u, uint, 16, 8, vabs) |
| 32 |
FUNC(s, int, 8, 16, vabs) |
| 33 |
FUNC(u, uint, 8, 16, vabs) |
| 34 |
FUNC_FLOAT(f, float, 32, 4, vabs) |
| 35 |
FUNC(f, float, 16, 8, vabs) |
| 36 |
|
| 37 |
/* Taking the absolute value of an unsigned value is a no-op, so half of the |
| 38 |
integer optimizations actually generate a call to memcpy, the other ones a |
| 39 |
'vabs'. */ |
| 40 |
/* { dg-final { scan-assembler-times {vabs.s[0-9]+\tq[0-9]+, q[0-9]+} 3 } } */ |
| 41 |
/* { dg-final { scan-assembler-times {vabs.f[0-9]+\tq[0-9]+, q[0-9]+} 2 } } */ |
| 42 |
/* { dg-final { scan-assembler-times {vldr[bhw].[0-9]+\tq[0-9]+} 5 } } */ |
| 43 |
/* { dg-final { scan-assembler-times {vstr[bhw].[0-9]+\tq[0-9]+} 5 } } */ |
| 44 |
/* { dg-final { scan-tree-dump-times "memcpy" 3 "optimized" } } */ |