1 /* { dg-do run { target int128 } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-mvsx" } */
5 /* This test should run the same on any target that supports vsx
6 instructions. Intentionally not specifying cpu in order to test
7 all code generation paths. */
11 extern void abort (void);
13 #define CONST0 (((unsigned __int128) 31415926539) << 60)
14 #define CONST1 (((unsigned __int128) 31415926539) << 54)
15 #define CONST2 (((unsigned __int128) 31415926539) << 48)
16 #define CONST3 (((unsigned __int128) 31415926539) << 32)
18 /* Test that indices > length of vector are applied modulo the vector
21 /* Test for vector residing in register. */
22 vector
unsigned __int128
e0 (vector
unsigned __int128 v
, unsigned __int128 x
)
24 return vec_insert (x
, v
, 0);
27 vector
unsigned __int128
e3 (vector
unsigned __int128 v
, unsigned __int128 x
)
29 return vec_insert (x
, v
, 3);
32 /* Test for vector residing in memory. */
33 vector
unsigned __int128
34 me0 (vector
unsigned __int128
*vp
, unsigned __int128 x
)
36 return vec_insert (x
, *vp
, 0);
39 vector
unsigned __int128
40 me3 (vector
unsigned __int128
*vp
, unsigned __int128 x
)
42 return vec_insert (x
, *vp
, 3);
45 /* Test the same with variable indices. */
47 /* Test for variable selector and vector residing in register. */
48 __attribute__((noinline
))
49 vector
unsigned __int128
50 ei (vector
unsigned __int128 v
, int i
, unsigned __int128 x
)
52 return vec_insert (x
, v
, i
);
55 /* Test for variable selector and vector residing in memory. */
56 __attribute__((noinline
))
57 vector
unsigned __int128
58 mei (vector
unsigned __int128
*vp
, int i
, unsigned __int128 x
)
60 return vec_insert (x
, *vp
, i
);
63 int main (int argc
, char *argv
[]) {
64 vector
unsigned __int128 dv
= { CONST0
};
74 dv
= me0 (&dv
, CONST1
);
78 dv
= me3 (&dv
, CONST3
);
82 dv
= ei (dv
, 0, CONST0
);
86 dv
= ei (dv
, 1, CONST1
);
90 dv
= ei (dv
, 2, CONST2
);
94 dv
= ei (dv
, 3, CONST3
);
98 dv
= mei (&dv
, 0, CONST0
);
102 dv
= mei (&dv
, 1, CONST1
);
103 if (dv
[0] != CONST1
)
106 dv
= mei (&dv
, 2, CONST2
);
107 if (dv
[0] != CONST2
)
110 dv
= mei (&dv
, 3, CONST3
);
111 if (dv
[0] != CONST3
)