Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/pr104253.c

raw
1 /*
2 * Require float128 support because __ibm128 currently is not enabled unless we
3 * also have __float128 support. We require software IEEE 128-bit support,
4 * which will work on power8. If we have hardware IEEE 128-bit support (power9
5 * or power10), ppc_float128_sw will still enable running the test.
6 */
7
8 /* { dg-do run } */
9 /* { dg-require-effective-target ppc_float128_sw } */
10 /* { dg-options "-O2 -mvsx -mfloat128" } */
11 /* { dg-prune-output ".-mfloat128. option may not be fully supported" } */
12
13 /*
14 * PR target/104253
15 *
16 * Verify that the various conversions to and from __ibm128 work. When the
17 * default for long double is changed to IEEE 128-bit, originally GCC would
18 * call the functions using an 'if' name instead of 'tf' name.
19 */
20
21 #include <stdlib.h>
22
23 extern float ibm128_to_sf (__ibm128) __attribute__((noinline));
24 extern double ibm128_to_df (__ibm128) __attribute__((noinline));
25 extern int ibm128_to_si (__ibm128) __attribute__((noinline));
26 extern long long ibm128_to_di (__ibm128) __attribute__((noinline));
27 extern unsigned int ibm128_to_usi (__ibm128) __attribute__((noinline));
28 extern unsigned long long ibm128_to_udi (__ibm128) __attribute__((noinline));
29
30 extern __ibm128 sf_to_ibm128 (float) __attribute__((noinline));
31 extern __ibm128 df_to_ibm128 (double) __attribute__((noinline));
32 extern __ibm128 si_to_ibm128 (int) __attribute__((noinline));
33 extern __ibm128 di_to_ibm128 (long long) __attribute__((noinline));
34 extern __ibm128 usi_to_ibm128 (unsigned int) __attribute__((noinline));
35 extern __ibm128 udi_to_ibm128 (unsigned long long) __attribute__((noinline));
36
37 float
38 ibm128_to_sf (__ibm128 x)
39 {
40 return x;
41 }
42
43 double
44 ibm128_to_df (__ibm128 x)
45 {
46 return x;
47 }
48
49 int
50 ibm128_to_si (__ibm128 x)
51 {
52 return x;
53 }
54
55 long long
56 ibm128_to_di (__ibm128 x)
57 {
58 return x;
59 }
60
61 unsigned int
62 ibm128_to_usi (__ibm128 x)
63 {
64 return x;
65 }
66
67 unsigned long long
68 ibm128_to_udi (__ibm128 x)
69 {
70 return x;
71 }
72
73 __ibm128
74 sf_to_ibm128 (float x)
75 {
76 return x;
77 }
78
79 __ibm128
80 df_to_ibm128 (double x)
81 {
82 return x;
83 }
84
85 __ibm128
86 si_to_ibm128 (int x)
87 {
88 return x;
89 }
90
91 __ibm128
92 di_to_ibm128 (long long x)
93 {
94 return x;
95 }
96
97 __ibm128
98 usi_to_ibm128 (unsigned int x)
99 {
100 return x;
101 }
102
103 __ibm128
104 udi_to_ibm128 (unsigned long long x)
105 {
106 return x;
107 }
108
109 volatile float seven_sf = 7.0f;
110 volatile double seven_df = 7.0;
111 volatile int seven_si = 7;
112 volatile long long seven_di = 7LL;
113 volatile unsigned int seven_usi = 7U;
114 volatile unsigned long long seven_udi = 7ULL;
115 volatile __ibm128 seven_ibm128 = 7.0;
116
117 int
118 main (void)
119 {
120 if (seven_ibm128 != sf_to_ibm128 (seven_sf))
121 abort ();
122
123 if (seven_ibm128 != df_to_ibm128 (seven_df))
124 abort ();
125
126 if (seven_ibm128 != si_to_ibm128 (seven_si))
127 abort ();
128
129 if (seven_ibm128 != di_to_ibm128 (seven_di))
130 abort ();
131
132 if (seven_ibm128 != usi_to_ibm128 (seven_usi))
133 abort ();
134
135 if (seven_ibm128 != udi_to_ibm128 (seven_udi))
136 abort ();
137
138 if (seven_sf != ibm128_to_sf (seven_ibm128))
139 abort ();
140
141 if (seven_df != ibm128_to_df (seven_ibm128))
142 abort ();
143
144 if (seven_si != ibm128_to_si (seven_ibm128))
145 abort ();
146
147 if (seven_di != ibm128_to_di (seven_ibm128))
148 abort ();
149
150 if (seven_usi != ibm128_to_usi (seven_ibm128))
151 abort ();
152
153 if (seven_udi != ibm128_to_udi (seven_ibm128))
154 abort ();
155
156 return 0;
157 }