zvector2.c
7.9 KB
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
212
213
214
215
216
217
218
// RUN: %clang_cc1 -triple s390x-linux-gnu -fzvector -target-cpu z14 \
// RUN: -flax-vector-conversions=none -W -Wall -Wconversion \
// RUN: -Werror -fsyntax-only -verify %s
vector signed char sc, sc2;
vector unsigned char uc, uc2;
vector bool char bc, bc2;
vector signed short ss, ss2;
vector unsigned short us, us2;
vector bool short bs, bs2;
vector signed int si, si2;
vector unsigned int ui, ui2;
vector bool int bi, bi2;
vector signed long long sl, sl2;
vector unsigned long long ul, ul2;
vector bool long long bl, bl2;
vector double fd, fd2;
vector float ff, ff2;
// Verify that __vector is also recognized
__vector float ff3;
// Verify operation of vec_step
int res_ff[vec_step(ff) == 4 ? 1 : -1];
void foo(void)
{
// -------------------------------------------------------------------------
// Test assignment.
// -------------------------------------------------------------------------
ff = ff2;
sc = ff2; // expected-error {{incompatible type}}
ff = sc2; // expected-error {{incompatible type}}
uc = ff2; // expected-error {{incompatible type}}
ff = uc2; // expected-error {{incompatible type}}
bc = ff2; // expected-error {{incompatible type}}
ff = bc2; // expected-error {{incompatible type}}
fd = ff2; // expected-error {{incompatible type}}
ff = fd2; // expected-error {{incompatible type}}
// -------------------------------------------------------------------------
// Test casts to same element width.
// -------------------------------------------------------------------------
ui = (vector unsigned int)ff2;
ff = (vector float)si2;
// -------------------------------------------------------------------------
// Test casts to different element width.
// -------------------------------------------------------------------------
uc = (vector unsigned char)ff2;
us = (vector unsigned short)ff2;
ul = (vector unsigned long long)ff2;
ff = (vector float)sc2;
ff = (vector float)ss2;
ff = (vector float)sl2;
// -------------------------------------------------------------------------
// Test unary operators.
// -------------------------------------------------------------------------
++ff2;
ff++;
--ff2;
ff--;
ff = +ff2;
ff = -ff2;
ff = ~ff2; // expected-error {{invalid argument}}
// -------------------------------------------------------------------------
// Test binary arithmetic operators.
// -------------------------------------------------------------------------
ff = ff + ff2;
ff = ff + ui2; // expected-error {{cannot convert}}
ff = si + ff2; // expected-error {{cannot convert}}
ff = fd + ff2; // expected-error {{cannot convert}}
ff += ff2;
ff += fd2; // expected-error {{cannot convert}}
sc += ff2; // expected-error {{cannot convert}}
ff = ff - ff2;
ff = ff - ui2; // expected-error {{cannot convert}}
ff = si - ff2; // expected-error {{cannot convert}}
ff = fd - ff2; // expected-error {{cannot convert}}
ff -= ff2;
ff -= fd2; // expected-error {{cannot convert}}
sc -= ff2; // expected-error {{cannot convert}}
ff = ff * ff2;
ff = ff * ui2; // expected-error {{cannot convert}}
ff = si * ff2; // expected-error {{cannot convert}}
ff = fd * ff2; // expected-error {{cannot convert}}
ff *= ff2;
ff *= fd2; // expected-error {{cannot convert}}
sc *= ff2; // expected-error {{cannot convert}}
ff = ff / ff2;
ff = ff / ui2; // expected-error {{cannot convert}}
ff = si / ff2; // expected-error {{cannot convert}}
ff = fd / ff2; // expected-error {{cannot convert}}
ff /= ff2;
ff /= fd2; // expected-error {{cannot convert}}
sc /= ff2; // expected-error {{cannot convert}}
ff = ff % ff2; // expected-error {{invalid operands}}
ff = ff % ui2; // expected-error {{invalid operands}}
ff = si % ff2; // expected-error {{invalid operands}}
ff = fd % ff2; // expected-error {{invalid operands}}
ff %= ff2; // expected-error {{invalid operands}}
ff %= fd2; // expected-error {{invalid operands}}
sc %= ff2; // expected-error {{invalid operands}}
// -------------------------------------------------------------------------
// Test bitwise binary operators.
// -------------------------------------------------------------------------
ff = ff & ff2; // expected-error {{invalid operands}}
ff = bi & ff2; // expected-error {{invalid operands}}
ff = fd & ff2; // expected-error {{invalid operands}}
ff = ff & bi2; // expected-error {{invalid operands}}
ff = ff & si2; // expected-error {{invalid operands}}
ff = ff & ui2; // expected-error {{invalid operands}}
sc &= ff2; // expected-error {{invalid operands}}
ff &= bc2; // expected-error {{invalid operands}}
ff &= fd2; // expected-error {{invalid operands}}
ff = ff | ff2; // expected-error {{invalid operands}}
ff = bi | ff2; // expected-error {{invalid operands}}
ff = fd | ff2; // expected-error {{invalid operands}}
ff = ff | bi2; // expected-error {{invalid operands}}
ff = ff | si2; // expected-error {{invalid operands}}
ff = ff | ui2; // expected-error {{invalid operands}}
sc |= ff2; // expected-error {{invalid operands}}
ff |= bc2; // expected-error {{invalid operands}}
ff |= fd2; // expected-error {{invalid operands}}
ff = ff ^ ff2; // expected-error {{invalid operands}}
ff = bi ^ ff2; // expected-error {{invalid operands}}
ff = fd ^ ff2; // expected-error {{invalid operands}}
ff = ff ^ bi2; // expected-error {{invalid operands}}
ff = ff ^ si2; // expected-error {{invalid operands}}
ff = ff ^ ui2; // expected-error {{invalid operands}}
sc ^= ff2; // expected-error {{invalid operands}}
ff ^= bc2; // expected-error {{invalid operands}}
ff ^= fd2; // expected-error {{invalid operands}}
// -------------------------------------------------------------------------
// Test shift operators.
// -------------------------------------------------------------------------
ff = ff << ff2; // expected-error {{integer is required}}
ff = ff << fd2; // expected-error {{integer is required}}
ff = ff << ui2; // expected-error {{integer is required}}
ff = sl << ff2; // expected-error {{integer is required}}
sc <<= ff2; // expected-error {{integer is required}}
ff <<= ff2; // expected-error {{integer is required}}
fd <<= ff2; // expected-error {{integer is required}}
ff = ff >> ff2; // expected-error {{integer is required}}
ff = ff >> fd2; // expected-error {{integer is required}}
ff = ff >> ui2; // expected-error {{integer is required}}
ff = sl >> ff2; // expected-error {{integer is required}}
sc >>= ff2; // expected-error {{integer is required}}
ff >>= ff2; // expected-error {{integer is required}}
fd >>= ff2; // expected-error {{integer is required}}
// -------------------------------------------------------------------------
// Test comparison operators.
// -------------------------------------------------------------------------
(void)(ff == ff2);
(void)(ff == fd2); // expected-error {{cannot convert}}
(void)(ff == ui2); // expected-error {{cannot convert}}
(void)(ui == ff2); // expected-error {{cannot convert}}
(void)(ff != ff2);
(void)(ff != fd2); // expected-error {{cannot convert}}
(void)(ff != ui2); // expected-error {{cannot convert}}
(void)(ui != ff2); // expected-error {{cannot convert}}
(void)(ff <= ff2);
(void)(ff <= fd2); // expected-error {{cannot convert}}
(void)(ff <= ui2); // expected-error {{cannot convert}}
(void)(ui <= ff2); // expected-error {{cannot convert}}
(void)(ff >= ff2);
(void)(ff >= fd2); // expected-error {{cannot convert}}
(void)(ff >= ui2); // expected-error {{cannot convert}}
(void)(ui >= ff2); // expected-error {{cannot convert}}
(void)(ff < ff2);
(void)(ff < fd2); // expected-error {{cannot convert}}
(void)(ff < ui2); // expected-error {{cannot convert}}
(void)(ui < ff2); // expected-error {{cannot convert}}
(void)(ff > ff2);
(void)(ff > fd2); // expected-error {{cannot convert}}
(void)(ff > ui2); // expected-error {{cannot convert}}
(void)(ui > ff2); // expected-error {{cannot convert}}
}