c++: normalizing ttp constraints [PR115656]
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / vsx-builtin-13d.c
blob257de552e64d12340b0ad4b887e00703dc60d64a
1 /* { dg-do run { target int128 } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-mvsx -O3" } */
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. */
9 #include <altivec.h>
11 #define SIGNED signed
13 extern void abort (void);
15 #define CONST0 (((SIGNED __int128) 31415926539) << 60)
16 #define CONST1 (((SIGNED __int128) 31415926539) << 55)
17 #define CONST2 (((SIGNED __int128) 31415926539) << 50)
18 #define CONST3 (((SIGNED __int128) 31415926539) << 45)
20 /* Test that indices > length of vector are applied modulo the vector
21 length. */
23 /* Test for vector residing in register. */
24 vector SIGNED __int128 e0 (vector SIGNED __int128 v, SIGNED __int128 x)
26 return vec_insert (x, v, 0);
29 vector SIGNED __int128 e3 (vector SIGNED __int128 v, SIGNED __int128 x)
31 return vec_insert (x, v, 3);
34 /* Test for vector residing in memory. */
35 vector SIGNED __int128 me0 (vector SIGNED __int128 *vp, SIGNED __int128 x)
37 return vec_insert (x, *vp, 0);
40 vector SIGNED __int128 me3 (vector SIGNED __int128 *vp, SIGNED __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 SIGNED __int128
50 ei (vector SIGNED __int128 v, int i, SIGNED __int128 x)
52 return vec_insert (x, v, i);
55 /* Test for variable selector and vector residing in memory. */
56 __attribute__((noinline))
57 vector SIGNED __int128
58 mei (vector SIGNED __int128 *vp, int i, SIGNED __int128 x)
60 return vec_insert (x, *vp, i);
63 int main (int argc, char *argv[]) {
64 vector SIGNED __int128 dv = { CONST0 };
65 SIGNED __int128 d;
67 dv = e0 (dv, CONST3);
68 if (dv [0] != CONST3)
69 abort ();
71 dv = e3 (dv, CONST1);
72 if (dv [0] != CONST1)
73 abort ();
75 dv = me0 (&dv, CONST2);
76 if (dv [0] != CONST2)
77 abort ();
79 dv = me3 (&dv, CONST3);
80 if (dv [0] != CONST3)
81 abort ();
83 dv = ei (dv, 0, CONST1);
84 if (dv [0] != CONST1)
85 abort ();
87 dv = ei (dv, 1, CONST2);
88 if (dv [0] != CONST2)
89 abort ();
91 dv = ei (dv, 2, CONST3);
92 if (dv [0] != CONST3)
93 abort ();
95 dv = ei (dv, 3, CONST1);
96 if (dv [0] != CONST1)
97 abort ();
99 dv = mei (&dv, 0, CONST2);
100 if (dv [0] != CONST2)
101 abort ();
103 dv = mei (&dv, 1, CONST3);
104 if (dv [0] != CONST3)
105 abort ();
107 dv = mei (&dv, 2, CONST1);
108 if (dv [0] != CONST1)
109 abort ();
111 dv = mei (&dv, 3, CONST2);
112 if (dv [0] != CONST2)
113 abort ();
114 return 0;