| ... | @@ -1316,110 +1316,6 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { | ... | @@ -1316,110 +1316,6 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 1316 | \\} | 1316 | \\} |
| 1317 | , ""); | 1317 | , ""); |
| 1318 | | 1318 | |
| 1319 | cases.add("basic vector expressions", | | |
| 1320 | \\#include <stdlib.h> | | |
| 1321 | \\#include <stdint.h> | | |
| 1322 | \\typedef int16_t __v8hi __attribute__((__vector_size__(16))); | | |
| 1323 | \\int main(int argc, char**argv) { | | |
| 1324 | \\ __v8hi uninitialized; | | |
| 1325 | \\ __v8hi empty_init = {}; | | |
| 1326 | \\ for (int i = 0; i < 8; i++) { | | |
| 1327 | \\ if (empty_init[i] != 0) abort(); | | |
| 1328 | \\ } | | |
| 1329 | \\ __v8hi partial_init = {0, 1, 2, 3}; | | |
| 1330 | \\ | | |
| 1331 | \\ __v8hi a = {0, 1, 2, 3, 4, 5, 6, 7}; | | |
| 1332 | \\ __v8hi b = (__v8hi) {100, 200, 300, 400, 500, 600, 700, 800}; | | |
| 1333 | \\ | | |
| 1334 | \\ __v8hi sum = a + b; | | |
| 1335 | \\ for (int i = 0; i < 8; i++) { | | |
| 1336 | \\ if (sum[i] != a[i] + b[i]) abort(); | | |
| 1337 | \\ } | | |
| 1338 | \\ return 0; | | |
| 1339 | \\} | | |
| 1340 | , ""); | | |
| 1341 | | | |
| 1342 | cases.add("__builtin_shufflevector", | | |
| 1343 | \\#include <stdlib.h> | | |
| 1344 | \\#include <stdint.h> | | |
| 1345 | \\typedef int16_t __v4hi __attribute__((__vector_size__(8))); | | |
| 1346 | \\typedef int16_t __v8hi __attribute__((__vector_size__(16))); | | |
| 1347 | \\int main(int argc, char**argv) { | | |
| 1348 | \\ __v8hi v8_a = {0, 1, 2, 3, 4, 5, 6, 7}; | | |
| 1349 | \\ __v8hi v8_b = {100, 200, 300, 400, 500, 600, 700, 800}; | | |
| 1350 | \\ __v8hi shuffled = __builtin_shufflevector(v8_a, v8_b, 0, 1, 2, 3, 8, 9, 10, 11); | | |
| 1351 | \\ for (int i = 0; i < 8; i++) { | | |
| 1352 | \\ if (i < 4) { | | |
| 1353 | \\ if (shuffled[i] != v8_a[i]) abort(); | | |
| 1354 | \\ } else { | | |
| 1355 | \\ if (shuffled[i] != v8_b[i - 4]) abort(); | | |
| 1356 | \\ } | | |
| 1357 | \\ } | | |
| 1358 | \\ shuffled = __builtin_shufflevector( | | |
| 1359 | \\ (__v8hi) {-1, -1, -1, -1, -1, -1, -1, -1}, | | |
| 1360 | \\ (__v8hi) {42, 42, 42, 42, 42, 42, 42, 42}, | | |
| 1361 | \\ 0, 1, 2, 3, 8, 9, 10, 11 | | |
| 1362 | \\ ); | | |
| 1363 | \\ for (int i = 0; i < 8; i++) { | | |
| 1364 | \\ if (i < 4) { | | |
| 1365 | \\ if (shuffled[i] != -1) abort(); | | |
| 1366 | \\ } else { | | |
| 1367 | \\ if (shuffled[i] != 42) abort(); | | |
| 1368 | \\ } | | |
| 1369 | \\ } | | |
| 1370 | \\ __v4hi shuffled_to_fewer_elements = __builtin_shufflevector(v8_a, v8_b, 0, 1, 8, 9); | | |
| 1371 | \\ for (int i = 0; i < 4; i++) { | | |
| 1372 | \\ if (i < 2) { | | |
| 1373 | \\ if (shuffled_to_fewer_elements[i] != v8_a[i]) abort(); | | |
| 1374 | \\ } else { | | |
| 1375 | \\ if (shuffled_to_fewer_elements[i] != v8_b[i - 2]) abort(); | | |
| 1376 | \\ } | | |
| 1377 | \\ } | | |
| 1378 | \\ __v4hi v4_a = {0, 1, 2, 3}; | | |
| 1379 | \\ __v4hi v4_b = {100, 200, 300, 400}; | | |
| 1380 | \\ __v8hi shuffled_to_more_elements = __builtin_shufflevector(v4_a, v4_b, 0, 1, 2, 3, 4, 5, 6, 7); | | |
| 1381 | \\ for (int i = 0; i < 4; i++) { | | |
| 1382 | \\ if (shuffled_to_more_elements[i] != v4_a[i]) abort(); | | |
| 1383 | \\ if (shuffled_to_more_elements[i + 4] != v4_b[i]) abort(); | | |
| 1384 | \\ } | | |
| 1385 | \\ return 0; | | |
| 1386 | \\} | | |
| 1387 | , ""); | | |
| 1388 | | | |
| 1389 | cases.add("__builtin_convertvector", | | |
| 1390 | \\#include <stdlib.h> | | |
| 1391 | \\#include <stdint.h> | | |
| 1392 | \\typedef int16_t __v8hi __attribute__((__vector_size__(16))); | | |
| 1393 | \\typedef uint16_t __v8hu __attribute__((__vector_size__(16))); | | |
| 1394 | \\int main(int argc, char**argv) { | | |
| 1395 | \\ __v8hi signed_vector = { 1, 2, 3, 4, -1, -2, -3,-4}; | | |
| 1396 | \\ __v8hu unsigned_vector = __builtin_convertvector(signed_vector, __v8hu); | | |
| 1397 | \\ | | |
| 1398 | \\ for (int i = 0; i < 8; i++) { | | |
| 1399 | \\ if (unsigned_vector[i] != (uint16_t)signed_vector[i]) abort(); | | |
| 1400 | \\ } | | |
| 1401 | \\ return 0; | | |
| 1402 | \\} | | |
| 1403 | , ""); | | |
| 1404 | | | |
| 1405 | cases.add("vector casting", | | |
| 1406 | \\#include <stdlib.h> | | |
| 1407 | \\#include <stdint.h> | | |
| 1408 | \\typedef int8_t __v8qi __attribute__((__vector_size__(8))); | | |
| 1409 | \\typedef uint8_t __v8qu __attribute__((__vector_size__(8))); | | |
| 1410 | \\int main(int argc, char**argv) { | | |
| 1411 | \\ __v8qi signed_vector = { 1, 2, 3, 4, -1, -2, -3,-4}; | | |
| 1412 | \\ | | |
| 1413 | \\ uint64_t big_int = (uint64_t) signed_vector; | | |
| 1414 | \\ if (big_int != 0x01020304FFFEFDFCULL && big_int != 0xFCFDFEFF04030201ULL) abort(); | | |
| 1415 | \\ __v8qu unsigned_vector = (__v8qu) big_int; | | |
| 1416 | \\ for (int i = 0; i < 8; i++) { | | |
| 1417 | \\ if (unsigned_vector[i] != (uint8_t)signed_vector[i] && unsigned_vector[i] != (uint8_t)signed_vector[7 - i]) abort(); | | |
| 1418 | \\ } | | |
| 1419 | \\ return 0; | | |
| 1420 | \\} | | |
| 1421 | , ""); | | |
| 1422 | | | |
| 1423 | cases.add("break from switch statement. Issue #8387", | 1319 | cases.add("break from switch statement. Issue #8387", |
| 1424 | \\#include <stdlib.h> | 1320 | \\#include <stdlib.h> |
| 1425 | \\int switcher(int x) { | 1321 | \\int switcher(int x) { |