[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / clang / test / Sema / zvector2.c
blob8a440374f335f509c26297d5a9c345ca34e3f605
1 // RUN: %clang_cc1 -triple s390x-linux-gnu -fzvector -target-cpu z14 \
2 // RUN: -flax-vector-conversions=none -W -Wall -Wconversion \
3 // RUN: -Werror -fsyntax-only -verify %s
5 vector signed char sc, sc2;
6 vector unsigned char uc, uc2;
7 vector bool char bc, bc2;
9 vector signed short ss, ss2;
10 vector unsigned short us, us2;
11 vector bool short bs, bs2;
13 vector signed int si, si2;
14 vector unsigned int ui, ui2;
15 vector bool int bi, bi2;
17 vector signed long long sl, sl2;
18 vector unsigned long long ul, ul2;
19 vector bool long long bl, bl2;
21 vector double fd, fd2;
23 vector float ff, ff2;
25 // Verify that __vector is also recognized
26 __vector float ff3;
28 // With z14 we support vector float, but still no vector _Complex float.
29 vector float _Complex cf; // expected-error {{cannot use '_Complex' with '__vector'}}
30 __vector float _Complex cf3; // expected-error {{cannot use '_Complex' with '__vector'}}
32 // Verify operation of vec_step
33 int res_ff[vec_step(ff) == 4 ? 1 : -1];
36 void foo(void)
38 // -------------------------------------------------------------------------
39 // Test assignment.
40 // -------------------------------------------------------------------------
42 ff = ff2;
44 sc = ff2; // expected-error {{incompatible type}}
45 ff = sc2; // expected-error {{incompatible type}}
47 uc = ff2; // expected-error {{incompatible type}}
48 ff = uc2; // expected-error {{incompatible type}}
50 bc = ff2; // expected-error {{incompatible type}}
51 ff = bc2; // expected-error {{incompatible type}}
53 fd = ff2; // expected-error {{incompatible type}}
54 ff = fd2; // expected-error {{incompatible type}}
56 // -------------------------------------------------------------------------
57 // Test casts to same element width.
58 // -------------------------------------------------------------------------
60 ui = (vector unsigned int)ff2;
61 ff = (vector float)si2;
63 // -------------------------------------------------------------------------
64 // Test casts to different element width.
65 // -------------------------------------------------------------------------
67 uc = (vector unsigned char)ff2;
68 us = (vector unsigned short)ff2;
69 ul = (vector unsigned long long)ff2;
71 ff = (vector float)sc2;
72 ff = (vector float)ss2;
73 ff = (vector float)sl2;
75 // -------------------------------------------------------------------------
76 // Test unary operators.
77 // -------------------------------------------------------------------------
79 ++ff2;
80 ff++;
82 --ff2;
83 ff--;
85 ff = +ff2;
87 ff = -ff2;
89 ff = ~ff2; // expected-error {{invalid argument}}
91 // -------------------------------------------------------------------------
92 // Test binary arithmetic operators.
93 // -------------------------------------------------------------------------
95 ff = ff + ff2;
96 ff = ff + ui2; // expected-error {{cannot convert}}
97 ff = si + ff2; // expected-error {{cannot convert}}
98 ff = fd + ff2; // expected-error {{cannot convert}}
99 ff += ff2;
100 ff += fd2; // expected-error {{cannot convert}}
101 sc += ff2; // expected-error {{cannot convert}}
103 ff = ff - ff2;
104 ff = ff - ui2; // expected-error {{cannot convert}}
105 ff = si - ff2; // expected-error {{cannot convert}}
106 ff = fd - ff2; // expected-error {{cannot convert}}
107 ff -= ff2;
108 ff -= fd2; // expected-error {{cannot convert}}
109 sc -= ff2; // expected-error {{cannot convert}}
111 ff = ff * ff2;
112 ff = ff * ui2; // expected-error {{cannot convert}}
113 ff = si * ff2; // expected-error {{cannot convert}}
114 ff = fd * ff2; // expected-error {{cannot convert}}
115 ff *= ff2;
116 ff *= fd2; // expected-error {{cannot convert}}
117 sc *= ff2; // expected-error {{cannot convert}}
119 ff = ff / ff2;
120 ff = ff / ui2; // expected-error {{cannot convert}}
121 ff = si / ff2; // expected-error {{cannot convert}}
122 ff = fd / ff2; // expected-error {{cannot convert}}
123 ff /= ff2;
124 ff /= fd2; // expected-error {{cannot convert}}
125 sc /= ff2; // expected-error {{cannot convert}}
127 ff = ff % ff2; // expected-error {{invalid operands}}
128 ff = ff % ui2; // expected-error {{invalid operands}}
129 ff = si % ff2; // expected-error {{invalid operands}}
130 ff = fd % ff2; // expected-error {{invalid operands}}
131 ff %= ff2; // expected-error {{invalid operands}}
132 ff %= fd2; // expected-error {{invalid operands}}
133 sc %= ff2; // expected-error {{invalid operands}}
135 // -------------------------------------------------------------------------
136 // Test bitwise binary operators.
137 // -------------------------------------------------------------------------
139 ff = ff & ff2; // expected-error {{invalid operands}}
140 ff = bi & ff2; // expected-error {{invalid operands}}
141 ff = fd & ff2; // expected-error {{invalid operands}}
142 ff = ff & bi2; // expected-error {{invalid operands}}
143 ff = ff & si2; // expected-error {{invalid operands}}
144 ff = ff & ui2; // expected-error {{invalid operands}}
145 sc &= ff2; // expected-error {{invalid operands}}
146 ff &= bc2; // expected-error {{invalid operands}}
147 ff &= fd2; // expected-error {{invalid operands}}
149 ff = ff | ff2; // expected-error {{invalid operands}}
150 ff = bi | ff2; // expected-error {{invalid operands}}
151 ff = fd | ff2; // expected-error {{invalid operands}}
152 ff = ff | bi2; // expected-error {{invalid operands}}
153 ff = ff | si2; // expected-error {{invalid operands}}
154 ff = ff | ui2; // expected-error {{invalid operands}}
155 sc |= ff2; // expected-error {{invalid operands}}
156 ff |= bc2; // expected-error {{invalid operands}}
157 ff |= fd2; // expected-error {{invalid operands}}
159 ff = ff ^ ff2; // expected-error {{invalid operands}}
160 ff = bi ^ ff2; // expected-error {{invalid operands}}
161 ff = fd ^ ff2; // expected-error {{invalid operands}}
162 ff = ff ^ bi2; // expected-error {{invalid operands}}
163 ff = ff ^ si2; // expected-error {{invalid operands}}
164 ff = ff ^ ui2; // expected-error {{invalid operands}}
165 sc ^= ff2; // expected-error {{invalid operands}}
166 ff ^= bc2; // expected-error {{invalid operands}}
167 ff ^= fd2; // expected-error {{invalid operands}}
169 // -------------------------------------------------------------------------
170 // Test shift operators.
171 // -------------------------------------------------------------------------
173 ff = ff << ff2; // expected-error {{integer is required}}
174 ff = ff << fd2; // expected-error {{integer is required}}
175 ff = ff << ui2; // expected-error {{integer is required}}
176 ff = sl << ff2; // expected-error {{integer is required}}
177 sc <<= ff2; // expected-error {{integer is required}}
178 ff <<= ff2; // expected-error {{integer is required}}
179 fd <<= ff2; // expected-error {{integer is required}}
181 ff = ff >> ff2; // expected-error {{integer is required}}
182 ff = ff >> fd2; // expected-error {{integer is required}}
183 ff = ff >> ui2; // expected-error {{integer is required}}
184 ff = sl >> ff2; // expected-error {{integer is required}}
185 sc >>= ff2; // expected-error {{integer is required}}
186 ff >>= ff2; // expected-error {{integer is required}}
187 fd >>= ff2; // expected-error {{integer is required}}
189 // -------------------------------------------------------------------------
190 // Test comparison operators.
191 // -------------------------------------------------------------------------
193 (void)(ff == ff2);
194 (void)(ff == fd2); // expected-error {{cannot convert}}
195 (void)(ff == ui2); // expected-error {{cannot convert}}
196 (void)(ui == ff2); // expected-error {{cannot convert}}
198 (void)(ff != ff2);
199 (void)(ff != fd2); // expected-error {{cannot convert}}
200 (void)(ff != ui2); // expected-error {{cannot convert}}
201 (void)(ui != ff2); // expected-error {{cannot convert}}
203 (void)(ff <= ff2);
204 (void)(ff <= fd2); // expected-error {{cannot convert}}
205 (void)(ff <= ui2); // expected-error {{cannot convert}}
206 (void)(ui <= ff2); // expected-error {{cannot convert}}
208 (void)(ff >= ff2);
209 (void)(ff >= fd2); // expected-error {{cannot convert}}
210 (void)(ff >= ui2); // expected-error {{cannot convert}}
211 (void)(ui >= ff2); // expected-error {{cannot convert}}
213 (void)(ff < ff2);
214 (void)(ff < fd2); // expected-error {{cannot convert}}
215 (void)(ff < ui2); // expected-error {{cannot convert}}
216 (void)(ui < ff2); // expected-error {{cannot convert}}
218 (void)(ff > ff2);
219 (void)(ff > fd2); // expected-error {{cannot convert}}
220 (void)(ff > ui2); // expected-error {{cannot convert}}
221 (void)(ui > ff2); // expected-error {{cannot convert}}