| 1 |
/* { dg-do run { target { powerpc*-*-* && lp64 } } } */ |
| 2 |
/* { dg-require-effective-target vsx_hw } */ |
| 3 |
/* { dg-options "-mvsx" } */ |
| 4 |
|
| 5 |
/* This test should run the same on any target that supports vsx |
| 6 |
instructions. Intentionally not specifying cpu in order to test |
| 7 |
all code generation paths. */ |
| 8 |
|
| 9 |
#include <altivec.h> |
| 10 |
|
| 11 |
extern void abort (void); |
| 12 |
|
| 13 |
/* Define PR89626 after that pr is addressed. */ |
| 14 |
#ifdef PR89626 |
| 15 |
#define SIGNED |
| 16 |
#else |
| 17 |
#define SIGNED signed |
| 18 |
#endif |
| 19 |
|
| 20 |
#define CONST0 (((__int128) 31415926539) << 60) |
| 21 |
|
| 22 |
/* Test that indices > length of vector are applied modulo the vector |
| 23 |
length. */ |
| 24 |
|
| 25 |
|
| 26 |
/* Test for variable selector and vector residing in register. */ |
| 27 |
__attribute__((noinline)) |
| 28 |
__int128 ei (vector SIGNED __int128 v, int i) |
| 29 |
{ |
| 30 |
return __builtin_vec_ext_v1ti (v, i); |
| 31 |
} |
| 32 |
|
| 33 |
/* Test for variable selector and vector residing in memory. */ |
| 34 |
__int128 mei (vector SIGNED __int128 *vp, int i) |
| 35 |
{ |
| 36 |
return __builtin_vec_ext_v1ti (*vp, i); |
| 37 |
} |
| 38 |
|
| 39 |
int main (int argc, char *argv[]) { |
| 40 |
vector SIGNED __int128 dv = { CONST0 }; |
| 41 |
__int128 d; |
| 42 |
|
| 43 |
d = ei (dv, 0); |
| 44 |
if (d != CONST0) |
| 45 |
abort (); |
| 46 |
|
| 47 |
d = ei (dv, 1); |
| 48 |
if (d != CONST0) |
| 49 |
abort (); |
| 50 |
|
| 51 |
d = ei (dv, 2); |
| 52 |
if (d != CONST0) |
| 53 |
abort (); |
| 54 |
|
| 55 |
d = ei (dv, 3); |
| 56 |
if (d != CONST0) |
| 57 |
abort (); |
| 58 |
|
| 59 |
d = mei (&dv, 0); |
| 60 |
if (d != CONST0) |
| 61 |
abort (); |
| 62 |
|
| 63 |
d = mei (&dv, 1); |
| 64 |
if (d != CONST0) |
| 65 |
abort (); |
| 66 |
|
| 67 |
d = mei (&dv, 2); |
| 68 |
if (d != CONST0) |
| 69 |
abort (); |
| 70 |
|
| 71 |
d = mei (&dv, 3); |
| 72 |
if (d != CONST0) |
| 73 |
abort (); |
| 74 |
|
| 75 |
return 0; |
| 76 |
} |