| 1 |
/* Test that using a character splat to set up a shift-right algebraic |
| 2 |
for a doubleword vector works correctly after gimple folding. */ |
| 3 |
|
| 4 |
/* { dg-do run { target { p8vector_hw } } } */ |
| 5 |
/* { dg-options "-O2 -mvsx" } */ |
| 6 |
/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ |
| 7 |
|
| 8 |
#include <altivec.h> |
| 9 |
|
| 10 |
typedef __vector unsigned long long vui64_t; |
| 11 |
typedef __vector long long vi64_t; |
| 12 |
|
| 13 |
static inline vi64_t |
| 14 |
vec_sradi (vi64_t vra, const unsigned int shb) |
| 15 |
{ |
| 16 |
vui64_t rshift; |
| 17 |
vi64_t result; |
| 18 |
|
| 19 |
/* Note legitimate use of wrong-type splat due to expectation that only |
| 20 |
lower 6-bits are read. */ |
| 21 |
rshift = (vui64_t) vec_splat_s8 (shb); |
| 22 |
|
| 23 |
/* Vector Shift Right Algebraic Doublewords based on the lower 6-bits |
| 24 |
of corresponding element of rshift. */ |
| 25 |
result = vec_vsrad (vra, rshift); |
| 26 |
|
| 27 |
return result; |
| 28 |
} |
| 29 |
|
| 30 |
__attribute__ ((noinline)) vi64_t |
| 31 |
test_sradi_4 (vi64_t a) |
| 32 |
{ |
| 33 |
return vec_sradi (a, 4); |
| 34 |
} |
| 35 |
|
| 36 |
int |
| 37 |
main () |
| 38 |
{ |
| 39 |
vi64_t x = {-256, 1025}; |
| 40 |
x = test_sradi_4 (x); |
| 41 |
if (x[0] != -16 || x[1] != 64) |
| 42 |
__builtin_abort (); |
| 43 |
return 0; |
| 44 |
} |