2015-05-04 Sandra Loosemore <sandra@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / vmx / insert-be-order.c
blob592ef28c0fc8cbe922a2a759f7252222de26ccb7
1 /* { dg-options "-maltivec=be -mabi=altivec -std=gnu99 -mno-vsx" } */
3 #include "harness.h"
5 static void test()
7 vector unsigned char va = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
8 vector signed char vb = {-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7};
9 vector unsigned short vc = {0,1,2,3,4,5,6,7};
10 vector signed short vd = {-4,-3,-2,-1,0,1,2,3};
11 vector unsigned int ve = {0,1,2,3};
12 vector signed int vf = {-2,-1,0,1};
13 vector float vg = {-2.0f,-1.0f,0.0f,1.0f};
15 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
16 check (vec_all_eq (vec_insert (16, va, 5),
17 ((vector unsigned char)
18 {0,1,2,3,4,5,6,7,8,9,16,11,12,13,14,15})),
19 "vec_insert (va LE)");
20 check (vec_all_eq (vec_insert (-16, vb, 0),
21 ((vector signed char)
22 {-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,-16})),
23 "vec_insert (vb LE)");
24 check (vec_all_eq (vec_insert (16, vc, 7),
25 ((vector unsigned short){16,1,2,3,4,5,6,7})),
26 "vec_insert (vc LE)");
27 check (vec_all_eq (vec_insert (-16, vd, 3),
28 ((vector signed short){-4,-3,-2,-1,-16,1,2,3})),
29 "vec_insert (vd LE)");
30 check (vec_all_eq (vec_insert (16, ve, 2),
31 ((vector unsigned int){0,16,2,3})),
32 "vec_insert (ve LE)");
33 check (vec_all_eq (vec_insert (-16, vf, 1),
34 ((vector signed int){-2,-1,-16,1})),
35 "vec_insert (vf LE)");
36 check (vec_all_eq (vec_insert (-16.0f, vg, 0),
37 ((vector float){-2.0f,-1.0f,0.0f,-16.0f})),
38 "vec_insert (vg LE)");
39 #else
40 check (vec_all_eq (vec_insert (16, va, 5),
41 ((vector unsigned char)
42 {0,1,2,3,4,16,6,7,8,9,10,11,12,13,14,15})),
43 "vec_insert (va BE)");
44 check (vec_all_eq (vec_insert (-16, vb, 0),
45 ((vector signed char)
46 {-16,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7})),
47 "vec_insert (vb BE)");
48 check (vec_all_eq (vec_insert (16, vc, 7),
49 ((vector unsigned short){0,1,2,3,4,5,6,16})),
50 "vec_insert (vc BE)");
51 check (vec_all_eq (vec_insert (-16, vd, 3),
52 ((vector signed short){-4,-3,-2,-16,0,1,2,3})),
53 "vec_insert (vd BE)");
54 check (vec_all_eq (vec_insert (16, ve, 2),
55 ((vector unsigned int){0,1,16,3})),
56 "vec_insert (ve BE)");
57 check (vec_all_eq (vec_insert (-16, vf, 1),
58 ((vector signed int){-2,-16,0,1})),
59 "vec_insert (vf BE)");
60 check (vec_all_eq (vec_insert (-16.0f, vg, 0),
61 ((vector float){-16.0f,-1.0f,0.0f,1.0f})),
62 "vec_insert (vg BE)");
63 #endif