| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target lp64 } */ |
| 3 |
/* Ensure there is no explicit -mno-vsx etc., otherwise |
| 4 |
the below bif __builtin_vec_vcmpeq_p replies on power8 |
| 5 |
vsx would fail. */ |
| 6 |
/* { dg-require-effective-target powerpc_vsx } */ |
| 7 |
/* { dg-options "-mdejagnu-cpu=power6 -maltivec -O2" } */ |
| 8 |
|
| 9 |
#include <altivec.h> |
| 10 |
|
| 11 |
#pragma GCC target ("cpu=power6,altivec") |
| 12 |
#ifdef _ARCH_PWR6 |
| 13 |
vector int |
| 14 |
test1 (vector int a, vector int b) |
| 15 |
{ |
| 16 |
return vec_add (a, b); |
| 17 |
} |
| 18 |
#else |
| 19 |
#error failed power6 pragma target |
| 20 |
#endif |
| 21 |
|
| 22 |
#pragma GCC target ("cpu=power7") |
| 23 |
/* Force a re-read of altivec.h with new cpu target. */ |
| 24 |
#undef _ALTIVEC_H |
| 25 |
#undef _RS6000_VECDEFINES_H |
| 26 |
#include <altivec.h> |
| 27 |
#ifdef _ARCH_PWR7 |
| 28 |
vector signed int |
| 29 |
test2 (vector signed int a, vector signed int b) |
| 30 |
{ |
| 31 |
return vec_sldw (a, b, 3); |
| 32 |
} |
| 33 |
#else |
| 34 |
#error failed to set power7 pragma target |
| 35 |
#endif |
| 36 |
|
| 37 |
#pragma GCC target ("cpu=power8") |
| 38 |
/* Force a re-read of altivec.h with new cpu target. */ |
| 39 |
#undef _ALTIVEC_H |
| 40 |
#undef _RS6000_VECDEFINES_H |
| 41 |
#include <altivec.h> |
| 42 |
#ifdef _ARCH_PWR8 |
| 43 |
vector int |
| 44 |
test3 (vector int a, vector int b) |
| 45 |
{ |
| 46 |
return vec_mergee (a, b); |
| 47 |
} |
| 48 |
typedef __attribute__((altivec(vector__))) long vec_t; |
| 49 |
int |
| 50 |
test3b (vec_t a, vec_t b) |
| 51 |
{ |
| 52 |
return __builtin_vec_vcmpeq_p (2, a, b); |
| 53 |
} |
| 54 |
#else |
| 55 |
#error failed to set power8 pragma target. |
| 56 |
#endif |
| 57 |
|