| 1 |
/* { dg-do run { target lp64 } } */ |
| 2 |
/* { dg-require-effective-target vsx_hw } */ |
| 3 |
/* { dg-options "-O2 -mvsx" } */ |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
#include <stddef.h> |
| 7 |
#include <altivec.h> |
| 8 |
|
| 9 |
#define ELEMENTS -12345.0, 23456.0 |
| 10 |
#define SPLAT 34567.0 |
| 11 |
|
| 12 |
vector double sv = (vector double) { ELEMENTS }; |
| 13 |
vector double splat = (vector double) { SPLAT, SPLAT }; |
| 14 |
vector double sv_global, sp_global; |
| 15 |
static vector double sv_static, sp_static; |
| 16 |
static const int expected[] = { ELEMENTS }; |
| 17 |
|
| 18 |
extern void check (vector double a) |
| 19 |
__attribute__((__noinline__)); |
| 20 |
|
| 21 |
extern void check_splat (vector double a) |
| 22 |
__attribute__((__noinline__)); |
| 23 |
|
| 24 |
extern vector double pack_reg (double a, double b) |
| 25 |
__attribute__((__noinline__)); |
| 26 |
|
| 27 |
extern vector double pack_from_ptr (double *p_a, double *p_b) |
| 28 |
__attribute__((__noinline__)); |
| 29 |
|
| 30 |
extern vector double pack_const (void) |
| 31 |
__attribute__((__noinline__)); |
| 32 |
|
| 33 |
extern void pack_ptr (vector double *p, double a, double b) |
| 34 |
__attribute__((__noinline__)); |
| 35 |
|
| 36 |
extern void pack_static (double a, double b) |
| 37 |
__attribute__((__noinline__)); |
| 38 |
|
| 39 |
extern void pack_global (double a, double b) |
| 40 |
__attribute__((__noinline__)); |
| 41 |
|
| 42 |
extern vector double splat_reg (double a) |
| 43 |
__attribute__((__noinline__)); |
| 44 |
|
| 45 |
extern vector double splat_from_ptr (double *p) |
| 46 |
__attribute__((__noinline__)); |
| 47 |
|
| 48 |
extern vector double splat_const (void) |
| 49 |
__attribute__((__noinline__)); |
| 50 |
|
| 51 |
extern void splat_ptr (vector double *p, double a) |
| 52 |
__attribute__((__noinline__)); |
| 53 |
|
| 54 |
extern void splat_static (double a) |
| 55 |
__attribute__((__noinline__)); |
| 56 |
|
| 57 |
extern void splat_global (double a) |
| 58 |
__attribute__((__noinline__)); |
| 59 |
|
| 60 |
void |
| 61 |
check (vector double a) |
| 62 |
{ |
| 63 |
size_t i; |
| 64 |
|
| 65 |
for (i = 0; i < 2; i++) |
| 66 |
if (vec_extract (a, i) != expected[i]) |
| 67 |
abort (); |
| 68 |
} |
| 69 |
|
| 70 |
void |
| 71 |
check_splat (vector double a) |
| 72 |
{ |
| 73 |
size_t i; |
| 74 |
|
| 75 |
for (i = 0; i < 2; i++) |
| 76 |
if (vec_extract (a, i) != SPLAT) |
| 77 |
abort (); |
| 78 |
} |
| 79 |
|
| 80 |
vector double |
| 81 |
pack_reg (double a, double b) |
| 82 |
{ |
| 83 |
return (vector double) { a, b }; |
| 84 |
} |
| 85 |
|
| 86 |
vector double |
| 87 |
pack_from_ptr (double *p_a, double *p_b) |
| 88 |
{ |
| 89 |
return (vector double) { *p_a, *p_b }; |
| 90 |
} |
| 91 |
|
| 92 |
vector double |
| 93 |
pack_const (void) |
| 94 |
{ |
| 95 |
return (vector double) { ELEMENTS }; |
| 96 |
} |
| 97 |
|
| 98 |
void |
| 99 |
pack_ptr (vector double *p, double a, double b) |
| 100 |
{ |
| 101 |
*p = (vector double) { a, b }; |
| 102 |
} |
| 103 |
|
| 104 |
void |
| 105 |
pack_static (double a, double b) |
| 106 |
{ |
| 107 |
sv_static = (vector double) { a, b }; |
| 108 |
} |
| 109 |
|
| 110 |
void |
| 111 |
pack_global (double a, double b) |
| 112 |
{ |
| 113 |
sv_global = (vector double) { a, b }; |
| 114 |
} |
| 115 |
|
| 116 |
vector double |
| 117 |
splat_reg (double a) |
| 118 |
{ |
| 119 |
return (vector double) { a, a }; |
| 120 |
} |
| 121 |
|
| 122 |
vector double |
| 123 |
splat_from_ptr (double *p) |
| 124 |
{ |
| 125 |
return (vector double) { *p, *p }; |
| 126 |
} |
| 127 |
|
| 128 |
vector double |
| 129 |
splat_const (void) |
| 130 |
{ |
| 131 |
return (vector double) { SPLAT, SPLAT }; |
| 132 |
} |
| 133 |
|
| 134 |
void |
| 135 |
splat_ptr (vector double *p, double a) |
| 136 |
{ |
| 137 |
*p = (vector double) { a, a }; |
| 138 |
} |
| 139 |
|
| 140 |
void |
| 141 |
splat_static (double a) |
| 142 |
{ |
| 143 |
sp_static = (vector double) { a, a }; |
| 144 |
} |
| 145 |
|
| 146 |
void |
| 147 |
splat_global (double a) |
| 148 |
{ |
| 149 |
sp_global = (vector double) { a, a }; |
| 150 |
} |
| 151 |
|
| 152 |
int main (void) |
| 153 |
{ |
| 154 |
vector double sv2, sv3; |
| 155 |
double mem = SPLAT; |
| 156 |
double mem2[2] = { ELEMENTS }; |
| 157 |
|
| 158 |
check (sv); |
| 159 |
|
| 160 |
check (pack_reg (ELEMENTS)); |
| 161 |
|
| 162 |
check (pack_from_ptr (&mem2[0], &mem2[1])); |
| 163 |
|
| 164 |
check (pack_const ()); |
| 165 |
|
| 166 |
pack_ptr (&sv2, ELEMENTS); |
| 167 |
check (sv2); |
| 168 |
|
| 169 |
pack_static (ELEMENTS); |
| 170 |
check (sv_static); |
| 171 |
|
| 172 |
pack_global (ELEMENTS); |
| 173 |
check (sv_global); |
| 174 |
|
| 175 |
check_splat (splat); |
| 176 |
|
| 177 |
check_splat (splat_reg (SPLAT)); |
| 178 |
|
| 179 |
check_splat (splat_from_ptr (&mem)); |
| 180 |
|
| 181 |
check_splat (splat_const ()); |
| 182 |
|
| 183 |
splat_ptr (&sv2, SPLAT); |
| 184 |
check_splat (sv2); |
| 185 |
|
| 186 |
splat_static (SPLAT); |
| 187 |
check_splat (sp_static); |
| 188 |
|
| 189 |
splat_global (SPLAT); |
| 190 |
check_splat (sp_global); |
| 191 |
|
| 192 |
return 0; |
| 193 |
} |