1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-require-effective-target vsx_hw } */
/* { dg-options "-mvsx -O0 -Wall" } */
#include <altivec.h>
#include <stdlib.h>
/* vec_ldl and vec_lvxl (an alias for vec_ldl) do an aligned vector
* load from memory, marking the fetched memory as least recently used
* (hinting that we do not anticipate a need to fetch this vector
* again within the near future.)
*
* vector <TYPE> result = vec_ldl (int offset, <TYPE> *address)
* vector <TYPE> result = vec_ldl (int offset, vector <TYPE> *address)
*
* The effect of these instructions is to perform the following:
*
* resuilt = *((vector <TTYPE> *)((((char *) address) + offset) & ~0x0f))
*
* This test exercises the following new prototypes of the vec_ldl
* service which were added in late March 2018:
*
* vector bool int vec_ldl (int, bool int *)
* vector bool short vec_ldl (int, bool short *)
* vector bool char vec_ldl (int, bool char *)
* vector double vec_ldl (int, double *)
* vector long long int vec_ldl (int, long long int *)
* vector unsigned long long int vec_ldl (int, unsigned long long int *)
* vector bool long long vec_ldl (int, bool long long *)
*/
static signed char ca[64] __attribute__((aligned(16)));
static unsigned char uca[64] __attribute__((aligned(16)));
static vector signed char *vcp = (vector signed char *) ca;
static unsigned vector char *vucp = (vector unsigned char *) uca;
static short sa[32] __attribute__((aligned(16)));
static unsigned short usa[32] __attribute__((aligned(16)));
static vector short *vsp = (vector short *) sa;
static unsigned vector short *vusp = (vector unsigned short *) usa;
static int ia[16] __attribute__((aligned(16)));
static unsigned int uia[16] __attribute__((aligned(16)));
static vector int *vip = (vector int *) ia;
static unsigned vector int *vuip = (vector unsigned int *) uia;
static long long la[8] __attribute__((aligned(16)));
static unsigned long long ula[8] __attribute__((aligned(16)));
static vector long long *vlp = (vector long long *) la;
static unsigned vector long long *vulp = (vector unsigned long long *) ula;
static double da[8] __attribute__((aligned(16)));
static vector double *vdp = (vector double *) da;
void
doInitialization ()
{
unsigned int i;
for (i = 0; i < 64; i++)
ca[i] = uca[i] = i;
for (i = 0; i < 32; i++)
sa[i] = usa[i] = i;
for (i = 0; i < 16; i++)
ia[i] = uia[i] = i;
for (i = 0; i < 8; i++)
la[i] = ula[i] = i;
for (i = 0; i < 8; i++)
da[i] = 0.125 * i;
}
int
main (int argc, char *argv[])
{
vector long long int lv;
vector unsigned long long int ulv;
vector int iv;
vector unsigned int uiv;
vector short sv;
vector unsigned short usv;
vector signed char cv;
vector unsigned char ucv;
vector double dv;
doInitialization ();
/* Do vector of char. */
for (int i = 0; i < 16; i++) {
/* Focus on ca[16] ... ca[31]. */
cv = vec_ldl (i+16, ca); /* compiler: invalid parameter combination */
if (cv[4] != ca[20])
abort ();
/* Focus on uca[32] ... uca[47]. */
ucv = vec_ldl (i+32, uca);
if (ucv[7] != uca[39])
abort ();
/* Focus on ca[0] ... ca[15]. */
cv = vec_ldl (i, vcp);
if (cv[3] != ca[3])
abort ();
/* Focus on ca[0] ... ca[15] while i <= 8.
Focus on ca[16] ... ca[31] while i > 8. */
ucv = vec_ldl (i+7, vucp);
if ((i+7 > 15) && (ucv[13] != uca[29]))
abort ();
if ((i + 7 <= 15) && (ucv[13] != uca[13]))
abort ();
}
/* Do vector of short. */
for (int i = 0; i < 16; i++) {
/* Focus on sa[8] ... sa[15]. */
sv = vec_ldl (i+16, sa);
if (sv[4] != sa[12])
abort ();
/* Focus on usa[24] ... usa[31]. */
usv = vec_ldl (i+48, usa);
if (usv[7] != usa[31])
abort ();
/* Focus on sa[0] ... sa[7]. */
sv = vec_ldl (i, vsp);
if (sv[3] != sa[3])
abort ();
/* Focus on usa[0] ... usa[7] while i <= 8.
Focus on usa[8] ... usa[15] while i > 8. */
usv = vec_ldl (i+7, vusp);
if ((i+7 > 15) && (usv[5] != usa[13]))
abort ();
if ((i + 7 <= 15) && (usv[5] != usa[5]))
abort ();
}
/* Do vector of int. */
for (int i = 0; i < 16; i++) {
/* Focus on ia[8] ... ia[11]. */
iv = vec_ldl (i+32, ia);
if (iv[3] != ia[11])
abort ();
/* Focus on uia[12] ... uia[15]. */
uiv = vec_ldl (i+48, uia);
if (uiv[2] != uia[14])
abort ();
/* Focus on ia[0] ... ia[3]. */
iv = vec_ldl (i, vip);
if (iv[3] != ia[3])
abort ();
/* Focus on uia[0] ... uia[3] while i <= 8.
Focus on uia[4] ... uia[7] while i > 8. */
uiv = vec_ldl (i+7, vuip);
if ((i+7 > 15) && (uiv[1] != uia[5]))
abort ();
if ((i + 7 <= 15) && (uiv[1] != uia[1]))
abort ();
}
/* Do vector of long long int. */
for (int i = 0; i < 16; i++) {
/* Focus on la[4] ... la[5]. */
lv = vec_ldl (i+32, la);
if (lv[1] != la[5])
abort ();
/* Focus on ula[6] ... ula[7]. */
ulv = vec_ldl (i+48, ula);
if (ulv[0] != uia[6])
abort ();
/* Focus on la[0] ... la[1]. */
lv = vec_ldl (i, vlp);
if (iv[1] != la[1])
abort ();
/* Focus on ula[0] ... uia[1] while i <= 8.
Focus on uia[2] ... uia[3] while i > 8. */
ulv = vec_ldl (i+7, vulp);
if ((i+7 > 15) && (ulv[1] != ula[3]))
abort ();
if ((i + 7 <= 15) && (ulv[1] != ula[1]))
abort ();
}
/* Do vector of double. */
for (int i = 0; i < 16; i++) {
/* Focus on da[2] ... da[3]. */
dv = vec_ldl (i+16, da);
if (dv[1] != da[3])
abort ();
/* Focus on da[6] ... da[7]. */
dv = vec_ldl (i+48, vdp);
if (dv[0] != da[6])
abort ();
/* Focus on da[0] ... da[1]. */
dv = vec_ldl (i, da);
if (dv[1] != da[1])
abort ();
/* Focus on da[0] ... da[1] while i <= 8.
Focus on da[2] ... da[3] while i > 8. */
dv = vec_ldl (i+7, vdp);
if ((i+7 <= 15) && (dv[1] != da[1]))
abort ();
if ((i + 7 > 15) && (dv[1] != da[3]))
abort ();
}
return 0;
}
|