Skip to content

Commit 347a02b

Browse files
committed
[clang][NFC] Repair tests for __builtin_convertvector on big-endian
Previously, the macro expansion to be explicit for the test cases had unintentionally forced the tests to always run in little-endian mode. This change restores the tests' endianness switch, and ensures that the tests always run on both a little- and big-endian platform.
1 parent 35fa46a commit 347a02b

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

clang/test/Sema/constant_builtins_vector.cpp

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension %s
2+
// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64-unknown-linux %s
3+
// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64le-unknown-linux %s
24

35
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
46
#define LITTLE_END 1
@@ -102,13 +104,13 @@ static_assert(__builtin_bit_cast(
102104
__builtin_shufflevector(from_vector4double_to_vector4char_var,
103105
from_vector4double_to_vector4char_var,
104106
0, 1, 2, 3)) ==
105-
(1 ? 0x03020100 : 0x00010203));
107+
(LITTLE_END ? 0x03020100 : 0x00010203));
106108
static_assert(__builtin_bit_cast(unsigned long long,
107109
__builtin_shufflevector(
108110
from_vector4double_to_vector4short_var,
109111
from_vector4double_to_vector4short_var, 0,
110112
1, 2, 3)) ==
111-
(1 ? 0x0003000200010000 : 0x0000000100020003));
113+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
112114
constexpr vector4double from_vector4float_to_vector4double_var =
113115
__builtin_convertvector((vector4float){0, 1, 2, 3}, vector4double);
114116
constexpr vector4float from_vector4float_to_vector4float_var =
@@ -131,13 +133,13 @@ static_assert(__builtin_bit_cast(unsigned,
131133
__builtin_shufflevector(
132134
from_vector4float_to_vector4char_var,
133135
from_vector4float_to_vector4char_var, 0, 1,
134-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
136+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
135137
static_assert(__builtin_bit_cast(
136138
unsigned long long,
137139
__builtin_shufflevector(from_vector4float_to_vector4short_var,
138140
from_vector4float_to_vector4short_var,
139141
0, 1, 2, 3)) ==
140-
(1 ? 0x0003000200010000 : 0x0000000100020003));
142+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
141143
constexpr vector4double from_vector4long_to_vector4double_var =
142144
__builtin_convertvector((vector4long){0, 1, 2, 3}, vector4double);
143145
constexpr vector4float from_vector4long_to_vector4float_var =
@@ -160,13 +162,13 @@ static_assert(__builtin_bit_cast(unsigned,
160162
__builtin_shufflevector(
161163
from_vector4long_to_vector4char_var,
162164
from_vector4long_to_vector4char_var, 0, 1,
163-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
165+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
164166
static_assert(__builtin_bit_cast(
165167
unsigned long long,
166168
__builtin_shufflevector(from_vector4long_to_vector4short_var,
167169
from_vector4long_to_vector4short_var,
168170
0, 1, 2, 3)) ==
169-
(1 ? 0x0003000200010000 : 0x0000000100020003));
171+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
170172
constexpr vector4double from_vector4int_to_vector4double_var =
171173
__builtin_convertvector((vector4int){0, 1, 2, 3}, vector4double);
172174
constexpr vector4float from_vector4int_to_vector4float_var =
@@ -189,13 +191,13 @@ static_assert(__builtin_bit_cast(unsigned,
189191
__builtin_shufflevector(
190192
from_vector4int_to_vector4char_var,
191193
from_vector4int_to_vector4char_var, 0, 1,
192-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
194+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
193195
static_assert(__builtin_bit_cast(
194196
unsigned long long,
195197
__builtin_shufflevector(from_vector4int_to_vector4short_var,
196198
from_vector4int_to_vector4short_var,
197199
0, 1, 2, 3)) ==
198-
(1 ? 0x0003000200010000 : 0x0000000100020003));
200+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
199201
constexpr vector4double from_vector4short_to_vector4double_var =
200202
__builtin_convertvector((vector4short){0, 1, 2, 3}, vector4double);
201203
constexpr vector4float from_vector4short_to_vector4float_var =
@@ -218,13 +220,13 @@ static_assert(__builtin_bit_cast(unsigned,
218220
__builtin_shufflevector(
219221
from_vector4short_to_vector4char_var,
220222
from_vector4short_to_vector4char_var, 0, 1,
221-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
223+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
222224
static_assert(__builtin_bit_cast(
223225
unsigned long long,
224226
__builtin_shufflevector(from_vector4short_to_vector4short_var,
225227
from_vector4short_to_vector4short_var,
226228
0, 1, 2, 3)) ==
227-
(1 ? 0x0003000200010000 : 0x0000000100020003));
229+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
228230
constexpr vector4double from_vector4char_to_vector4double_var =
229231
__builtin_convertvector((vector4char){0, 1, 2, 3}, vector4double);
230232
constexpr vector4float from_vector4char_to_vector4float_var =
@@ -247,13 +249,13 @@ static_assert(__builtin_bit_cast(unsigned,
247249
__builtin_shufflevector(
248250
from_vector4char_to_vector4char_var,
249251
from_vector4char_to_vector4char_var, 0, 1,
250-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
252+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
251253
static_assert(__builtin_bit_cast(
252254
unsigned long long,
253255
__builtin_shufflevector(from_vector4char_to_vector4short_var,
254256
from_vector4char_to_vector4short_var,
255257
0, 1, 2, 3)) ==
256-
(1 ? 0x0003000200010000 : 0x0000000100020003));
258+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
257259
constexpr vector4double from_vector4BitInt8_to_vector4double_var =
258260
__builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4double);
259261
constexpr vector4float from_vector4BitInt8_to_vector4float_var =
@@ -277,13 +279,13 @@ static_assert(__builtin_bit_cast(unsigned,
277279
from_vector4BitInt8_to_vector4char_var,
278280
from_vector4BitInt8_to_vector4char_var, 0,
279281
1, 2, 3)) ==
280-
(1 ? 0x03020100 : 0x00010203));
282+
(LITTLE_END ? 0x03020100 : 0x00010203));
281283
static_assert(__builtin_bit_cast(unsigned long long,
282284
__builtin_shufflevector(
283285
from_vector4BitInt8_to_vector4short_var,
284286
from_vector4BitInt8_to_vector4short_var, 0,
285287
1, 2, 3)) ==
286-
(1 ? 0x0003000200010000 : 0x0000000100020003));
288+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
287289
constexpr vector4double from_vector4BitInt32_to_vector4double_var =
288290
__builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4double);
289291
constexpr vector4float from_vector4BitInt32_to_vector4float_var =
@@ -307,13 +309,13 @@ static_assert(__builtin_bit_cast(unsigned,
307309
from_vector4BitInt32_to_vector4char_var,
308310
from_vector4BitInt32_to_vector4char_var, 0,
309311
1, 2, 3)) ==
310-
(1 ? 0x03020100 : 0x00010203));
312+
(LITTLE_END ? 0x03020100 : 0x00010203));
311313
static_assert(__builtin_bit_cast(unsigned long long,
312314
__builtin_shufflevector(
313315
from_vector4BitInt32_to_vector4short_var,
314316
from_vector4BitInt32_to_vector4short_var,
315317
0, 1, 2, 3)) ==
316-
(1 ? 0x0003000200010000 : 0x0000000100020003));
318+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
317319
constexpr vector4double from_vector4BitInt128_to_vector4double_var =
318320
__builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4double);
319321
constexpr vector4float from_vector4BitInt128_to_vector4float_var =
@@ -337,13 +339,13 @@ static_assert(__builtin_bit_cast(unsigned,
337339
from_vector4BitInt128_to_vector4char_var,
338340
from_vector4BitInt128_to_vector4char_var,
339341
0, 1, 2, 3)) ==
340-
(1 ? 0x03020100 : 0x00010203));
342+
(LITTLE_END ? 0x03020100 : 0x00010203));
341343
static_assert(__builtin_bit_cast(unsigned long long,
342344
__builtin_shufflevector(
343345
from_vector4BitInt128_to_vector4short_var,
344346
from_vector4BitInt128_to_vector4short_var,
345347
0, 1, 2, 3)) ==
346-
(1 ? 0x0003000200010000 : 0x0000000100020003));
348+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
347349
;
348350
constexpr vector8double from_vector8double_to_vector8double_var =
349351
__builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},
@@ -377,13 +379,13 @@ static_assert(__builtin_bit_cast(
377379
__builtin_shufflevector(from_vector8double_to_vector8char_var,
378380
from_vector8double_to_vector8char_var,
379381
0, 1, 2, 3)) ==
380-
(1 ? 0x03020100 : 0x00010203));
382+
(LITTLE_END ? 0x03020100 : 0x00010203));
381383
static_assert(__builtin_bit_cast(unsigned long long,
382384
__builtin_shufflevector(
383385
from_vector8double_to_vector8short_var,
384386
from_vector8double_to_vector8short_var, 0,
385387
1, 2, 3)) ==
386-
(1 ? 0x0003000200010000 : 0x0000000100020003));
388+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
387389
constexpr vector8double from_vector8float_to_vector8double_var =
388390
__builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},
389391
vector8double);
@@ -414,13 +416,13 @@ static_assert(__builtin_bit_cast(unsigned,
414416
__builtin_shufflevector(
415417
from_vector8float_to_vector8char_var,
416418
from_vector8float_to_vector8char_var, 0, 1,
417-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
419+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
418420
static_assert(__builtin_bit_cast(
419421
unsigned long long,
420422
__builtin_shufflevector(from_vector8float_to_vector8short_var,
421423
from_vector8float_to_vector8short_var,
422424
0, 1, 2, 3)) ==
423-
(1 ? 0x0003000200010000 : 0x0000000100020003));
425+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
424426
constexpr vector8double from_vector8long_to_vector8double_var =
425427
__builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},
426428
vector8double);
@@ -449,13 +451,13 @@ static_assert(__builtin_bit_cast(unsigned,
449451
__builtin_shufflevector(
450452
from_vector8long_to_vector8char_var,
451453
from_vector8long_to_vector8char_var, 0, 1,
452-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
454+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
453455
static_assert(__builtin_bit_cast(
454456
unsigned long long,
455457
__builtin_shufflevector(from_vector8long_to_vector8short_var,
456458
from_vector8long_to_vector8short_var,
457459
0, 1, 2, 3)) ==
458-
(1 ? 0x0003000200010000 : 0x0000000100020003));
460+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
459461
constexpr vector8double from_vector8int_to_vector8double_var =
460462
__builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7},
461463
vector8double);
@@ -482,13 +484,13 @@ static_assert(__builtin_bit_cast(unsigned,
482484
__builtin_shufflevector(
483485
from_vector8int_to_vector8char_var,
484486
from_vector8int_to_vector8char_var, 0, 1,
485-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
487+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
486488
static_assert(__builtin_bit_cast(
487489
unsigned long long,
488490
__builtin_shufflevector(from_vector8int_to_vector8short_var,
489491
from_vector8int_to_vector8short_var,
490492
0, 1, 2, 3)) ==
491-
(1 ? 0x0003000200010000 : 0x0000000100020003));
493+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
492494
constexpr vector8double from_vector8short_to_vector8double_var =
493495
__builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},
494496
vector8double);
@@ -519,13 +521,13 @@ static_assert(__builtin_bit_cast(unsigned,
519521
__builtin_shufflevector(
520522
from_vector8short_to_vector8char_var,
521523
from_vector8short_to_vector8char_var, 0, 1,
522-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
524+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
523525
static_assert(__builtin_bit_cast(
524526
unsigned long long,
525527
__builtin_shufflevector(from_vector8short_to_vector8short_var,
526528
from_vector8short_to_vector8short_var,
527529
0, 1, 2, 3)) ==
528-
(1 ? 0x0003000200010000 : 0x0000000100020003));
530+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
529531
constexpr vector8double from_vector8char_to_vector8double_var =
530532
__builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},
531533
vector8double);
@@ -554,13 +556,13 @@ static_assert(__builtin_bit_cast(unsigned,
554556
__builtin_shufflevector(
555557
from_vector8char_to_vector8char_var,
556558
from_vector8char_to_vector8char_var, 0, 1,
557-
2, 3)) == (1 ? 0x03020100 : 0x00010203));
559+
2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));
558560
static_assert(__builtin_bit_cast(
559561
unsigned long long,
560562
__builtin_shufflevector(from_vector8char_to_vector8short_var,
561563
from_vector8char_to_vector8short_var,
562564
0, 1, 2, 3)) ==
563-
(1 ? 0x0003000200010000 : 0x0000000100020003));
565+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
564566
constexpr vector8double from_vector8BitInt8_to_vector8double_var =
565567
__builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},
566568
vector8double);
@@ -593,13 +595,13 @@ static_assert(__builtin_bit_cast(unsigned,
593595
from_vector8BitInt8_to_vector8char_var,
594596
from_vector8BitInt8_to_vector8char_var, 0,
595597
1, 2, 3)) ==
596-
(1 ? 0x03020100 : 0x00010203));
598+
(LITTLE_END ? 0x03020100 : 0x00010203));
597599
static_assert(__builtin_bit_cast(unsigned long long,
598600
__builtin_shufflevector(
599601
from_vector8BitInt8_to_vector8short_var,
600602
from_vector8BitInt8_to_vector8short_var, 0,
601603
1, 2, 3)) ==
602-
(1 ? 0x0003000200010000 : 0x0000000100020003));
604+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
603605
constexpr vector8double from_vector8BitInt32_to_vector8double_var =
604606
__builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},
605607
vector8double);
@@ -632,13 +634,13 @@ static_assert(__builtin_bit_cast(unsigned,
632634
from_vector8BitInt32_to_vector8char_var,
633635
from_vector8BitInt32_to_vector8char_var, 0,
634636
1, 2, 3)) ==
635-
(1 ? 0x03020100 : 0x00010203));
637+
(LITTLE_END ? 0x03020100 : 0x00010203));
636638
static_assert(__builtin_bit_cast(unsigned long long,
637639
__builtin_shufflevector(
638640
from_vector8BitInt32_to_vector8short_var,
639641
from_vector8BitInt32_to_vector8short_var,
640642
0, 1, 2, 3)) ==
641-
(1 ? 0x0003000200010000 : 0x0000000100020003));
643+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
642644
constexpr vector8double from_vector8BitInt128_to_vector8double_var =
643645
__builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},
644646
vector8double);
@@ -671,13 +673,13 @@ static_assert(__builtin_bit_cast(unsigned,
671673
from_vector8BitInt128_to_vector8char_var,
672674
from_vector8BitInt128_to_vector8char_var,
673675
0, 1, 2, 3)) ==
674-
(1 ? 0x03020100 : 0x00010203));
676+
(LITTLE_END ? 0x03020100 : 0x00010203));
675677
static_assert(__builtin_bit_cast(unsigned long long,
676678
__builtin_shufflevector(
677679
from_vector8BitInt128_to_vector8short_var,
678680
from_vector8BitInt128_to_vector8short_var,
679681
0, 1, 2, 3)) ==
680-
(1 ? 0x0003000200010000 : 0x0000000100020003));
682+
(LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));
681683
;
682684
#undef CHECK_ALL_COMBINATIONS
683685
#undef CHECK_TO_ALL_TYPES

0 commit comments

Comments
 (0)