| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target powerpc_vsx } */ |
| 3 |
/* { dg-options "-mcpu=power9 -O2" } */ |
| 4 |
|
| 5 |
/* Optimize vector shifts by constants. */ |
| 6 |
|
| 7 |
#include <altivec.h> |
| 8 |
|
| 9 |
typedef vector long long vi64_t; |
| 10 |
typedef vector unsigned long long vui64_t; |
| 11 |
|
| 12 |
typedef vector int vi32_t; |
| 13 |
typedef vector unsigned int vui32_t; |
| 14 |
|
| 15 |
vi64_t |
| 16 |
shiftra_test64_4 (vi64_t a) |
| 17 |
{ |
| 18 |
vui64_t x = {4, 4}; |
| 19 |
return (vi64_t) vec_vsrad (a, x); |
| 20 |
} |
| 21 |
|
| 22 |
vi64_t |
| 23 |
shiftrl_test64_4 (vi64_t a) |
| 24 |
{ |
| 25 |
vui64_t x = {4, 4}; |
| 26 |
return (vi64_t) vec_vsrd (a, x); |
| 27 |
} |
| 28 |
|
| 29 |
vi64_t |
| 30 |
shiftl_test64_4 (vi64_t a) |
| 31 |
{ |
| 32 |
vui64_t x = {4, 4}; |
| 33 |
return (vi64_t) vec_vsld (a, x); |
| 34 |
} |
| 35 |
|
| 36 |
vi64_t |
| 37 |
shiftra_test64_29 (vi64_t a) |
| 38 |
{ |
| 39 |
vui64_t x = {29, 29}; |
| 40 |
return (vi64_t) vec_vsrad (a, x); |
| 41 |
} |
| 42 |
|
| 43 |
vi64_t |
| 44 |
shiftrl_test64_29 (vi64_t a) |
| 45 |
{ |
| 46 |
vui64_t x = {29, 29}; |
| 47 |
return (vi64_t) vec_vsrd (a, x); |
| 48 |
} |
| 49 |
|
| 50 |
vi64_t |
| 51 |
shiftl_test64_29 (vi64_t a) |
| 52 |
{ |
| 53 |
vui64_t x = {29, 29}; |
| 54 |
return (vi64_t) vec_vsld (a, x); |
| 55 |
} |
| 56 |
|
| 57 |
vi32_t |
| 58 |
shiftra_test32_4 (vi32_t a) |
| 59 |
{ |
| 60 |
vui32_t x = {4, 4, 4, 4}; |
| 61 |
return (vi32_t) vec_vsraw (a, x); |
| 62 |
} |
| 63 |
|
| 64 |
vi32_t |
| 65 |
shiftrl_test32_4 (vi32_t a) |
| 66 |
{ |
| 67 |
vui32_t x = {4, 4, 4, 4}; |
| 68 |
return (vi32_t) vec_vsrw (a, x); |
| 69 |
} |
| 70 |
|
| 71 |
vi32_t |
| 72 |
shiftl_test32_4 (vi32_t a) |
| 73 |
{ |
| 74 |
vui32_t x = {4, 4, 4, 4}; |
| 75 |
return (vi32_t) vec_vslw (a, x); |
| 76 |
} |
| 77 |
|
| 78 |
vi32_t |
| 79 |
shiftra_test32_29 (vi32_t a) |
| 80 |
{ |
| 81 |
vui32_t x = {29, 29, 29, 29}; |
| 82 |
return (vi32_t) vec_vsraw (a, x); |
| 83 |
} |
| 84 |
|
| 85 |
vi32_t |
| 86 |
shiftrl_test32_29 (vi32_t a) |
| 87 |
{ |
| 88 |
vui32_t x = {29, 29, 29, 29}; |
| 89 |
return (vi32_t) vec_vsrw (a, x); |
| 90 |
} |
| 91 |
|
| 92 |
vi32_t |
| 93 |
shiftl_test32_29 (vi32_t a) |
| 94 |
{ |
| 95 |
vui32_t x = {29, 29, 29, 29}; |
| 96 |
return (vi32_t) vec_vslw (a, x); |
| 97 |
} |
| 98 |
|
| 99 |
/* { dg-final { scan-assembler-times {\mxxspltib\M} 6 } } */ |
| 100 |
/* { dg-final { scan-assembler-times {\mvsld\M} 2 } } */ |
| 101 |
/* { dg-final { scan-assembler-times {\mvslw\M} 2 } } */ |
| 102 |
/* { dg-final { scan-assembler-times {\mvspltisw\M} 6 } } */ |
| 103 |
/* { dg-final { scan-assembler-times {\mvsrd\M} 2 } } */ |
| 104 |
/* { dg-final { scan-assembler-times {\mvsrw\M} 2 } } */ |
| 105 |
/* { dg-final { scan-assembler-times {\mvsrad\M} 2 } } */ |
| 106 |
/* { dg-final { scan-assembler-times {\mvsraw\M} 2 } } */ |