1 /* { dg-do run { target { powerpc*-*-linux* } } } */
2 /* { dg-require-effective-target ppc_float128_sw } */
3 /* { dg-require-effective-target vsx_hw } */
4 /* { dg-options "-mvsx -O2" } */
6 /* This is the same as test float128-1.c, using the _Float128 keyword instead
7 of __float128, and not using -mfloat128. */
16 #if !defined(__FLOAT128__) || !defined(_ARCH_PPC)
18 pass_through (_Float128 x
)
23 _Float128 (*no_optimize
) (_Float128
) = pass_through
;
27 __attribute__((__noinline__
))
29 print_f128 (_Float128 x
)
38 #if defined(_ARCH_PPC) && defined(__BIG_ENDIAN__)
44 #elif (defined(_ARCH_PPC) && defined(__LITTLE_ENDIAN__)) || defined(__x86_64__)
51 #error "Unknown system"
63 sign
= (unsigned)((upper
>> 63) & 1);
64 exponent
= (unsigned)((upper
>> 48) & ((((uint64_t)1) << 16) - 1));
65 mantissa1
= (upper
& ((((uint64_t)1) << 48) - 1));
68 printf ("%c 0x%.4x 0x%.12" PRIx64
" 0x%.16" PRIx64
,
76 __attribute__((__noinline__
))
78 do_test (_Float128 expected
, _Float128 got
, const char *name
)
80 int equal_p
= (expected
== got
);
83 printf ("Test %s, expected: ", name
);
84 print_f128 (expected
);
85 printf (" %5g, got: ", (double) expected
);
87 printf (" %5g, result %s\n",
89 (equal_p
) ? "equal" : "not equal");
100 _Float128 one
= 1.0f128
;
101 _Float128 two
= 2.0f128
;
102 _Float128 three
= 3.0f128
;
103 _Float128 four
= 4.0f128
;
104 _Float128 five
= 5.0f128
;
105 _Float128 add_result
= (1.0f128
+ 2.0f128
);
106 _Float128 mul_result
= ((1.0f128
+ 2.0f128
) * 3.0f128
);
107 _Float128 div_result
= (((1.0f128
+ 2.0f128
) * 3.0f128
) / 4.0f128
);
108 _Float128 sub_result
= ((((1.0f128
+ 2.0f128
) * 3.0f128
) / 4.0f128
)
110 _Float128 neg_result
= - sub_result
;
111 _Float128 add_xresult
;
112 _Float128 mul_xresult
;
113 _Float128 div_xresult
;
114 _Float128 sub_xresult
;
115 _Float128 neg_xresult
;
117 #if defined(__FLOAT128__) && defined(_ARCH_PPC)
118 __asm__ (" #prevent constant folding, %x0" : "+wa" (one
));
119 __asm__ (" #prevent constant folding, %x0" : "+wa" (two
));
120 __asm__ (" #prevent constant folding, %x0" : "+wa" (three
));
121 __asm__ (" #prevent constant folding, %x0" : "+wa" (four
));
122 __asm__ (" #prevent constant folding, %x0" : "+wa" (five
));
125 one
= no_optimize (one
);
126 two
= no_optimize (two
);
127 three
= no_optimize (three
);
128 four
= no_optimize (four
);
129 five
= no_optimize (five
);
132 add_xresult
= (one
+ two
);
133 do_test (add_result
, add_xresult
, "add");
135 mul_xresult
= add_xresult
* three
;
136 do_test (mul_result
, mul_xresult
, "mul");
138 div_xresult
= mul_xresult
/ four
;
139 do_test (div_result
, div_xresult
, "div");
141 sub_xresult
= div_xresult
- five
;
142 do_test (sub_result
, sub_xresult
, "sub");
144 neg_xresult
= - sub_xresult
;
145 do_test (neg_result
, neg_xresult
, "neg");