Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/vsx-builtin-20c.c

raw
1 /* { dg-do run { target int128 } } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-mvsx" } */
4
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. */
8
9 #include <altivec.h>
10
11 extern void abort (void);
12
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)
17
18 /* Test that indices > length of vector are applied modulo the vector
19 length. */
20
21 /* Test for vector residing in register. */
22 vector unsigned __int128 e0 (vector unsigned __int128 v, unsigned __int128 x)
23 {
24 return vec_insert (x, v, 0);
25 }
26
27 vector unsigned __int128 e3 (vector unsigned __int128 v, unsigned __int128 x)
28 {
29 return vec_insert (x, v, 3);
30 }
31
32 /* Test for vector residing in memory. */
33 vector unsigned __int128
34 me0 (vector unsigned __int128 *vp, unsigned __int128 x)
35 {
36 return vec_insert (x, *vp, 0);
37 }
38
39 vector unsigned __int128
40 me3 (vector unsigned __int128 *vp, unsigned __int128 x)
41 {
42 return vec_insert (x, *vp, 3);
43 }
44
45 /* Test the same with variable indices. */
46
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)
51 {
52 return vec_insert (x, v, i);
53 }
54
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)
59 {
60 return vec_insert (x, *vp, i);
61 }
62
63 int main (int argc, char *argv[]) {
64 vector unsigned __int128 dv = { CONST0 };
65
66 dv = e0 (dv, CONST3);
67 if (dv [0] != CONST3)
68 abort ();
69
70 dv = e3 (dv, CONST2);
71 if (dv [0] != CONST2)
72 abort ();
73
74 dv = me0 (&dv, CONST1);
75 if (dv [0] != CONST1)
76 abort ();
77
78 dv = me3 (&dv, CONST3);
79 if (dv [0] != CONST3)
80 abort ();
81
82 dv = ei (dv, 0, CONST0);
83 if (dv [0] != CONST0)
84 abort ();
85
86 dv = ei (dv, 1, CONST1);
87 if (dv [0] != CONST1)
88 abort ();
89
90 dv = ei (dv, 2, CONST2);
91 if (dv [0] != CONST2)
92 abort ();
93
94 dv = ei (dv, 3, CONST3);
95 if (dv [0] != CONST3)
96 abort ();
97
98 dv = mei (&dv, 0, CONST0);
99 if (dv [0] != CONST0)
100 abort ();
101
102 dv = mei (&dv, 1, CONST1);
103 if (dv [0] != CONST1)
104 abort ();
105
106 dv = mei (&dv, 2, CONST2);
107 if (dv [0] != CONST2)
108 abort ();
109
110 dv = mei (&dv, 3, CONST3);
111 if (dv [0] != CONST3)
112 abort ();
113
114 return 0;
115 }