* lib/target-supports.exp (check_effective_target_hard_dfp): New.
[official-gcc.git] / gcc / testsuite / gcc.dg / dfp / fe-binop.c
blob23f137818ed721b7f81d3d1bf42befbf715d7462
1 /* { dg-options "-std=gnu99" } */
2 /* { dg-skip-if "test is for emulation" { hard_dfp } { "*" } { "" } } */
4 /* Touch tests that check for raising appropriate exceptions for binary
5 arithmetic operations on decimal float values. */
7 #include "fe-check.h"
9 volatile _Decimal32 a32, b32, c32;
10 volatile _Decimal64 a64, b64, c64;
11 volatile _Decimal128 a128, b128, c128;
12 _Decimal32 inf32;
13 _Decimal64 inf64;
14 _Decimal128 inf128;
16 BINOP (100, /, a32, 2.0df, b32, 0.df, c32, FE_DIVBYZERO)
17 BINOP (101, /, a64, 2.0dd, b64, 0.dd, c64, FE_DIVBYZERO)
18 BINOP (102, /, a128, 2.0dl, b128, 0.dl, c128, FE_DIVBYZERO)
20 BINOP (200, /, a32, 0.df, b32, 0.df, c32, FE_INVALID)
21 BINOP (201, /, a64, 0.dd, b64, 0.dd, c64, FE_INVALID)
22 BINOP (202, /, a128, 0.dl, b128, 0.dl, c128, FE_INVALID)
23 BINOP (203, /, a32, inf32, b32, inf32, c32, FE_INVALID)
24 BINOP (204, /, a64, inf64, b64, inf64, c64, FE_INVALID)
25 BINOP (205, /, a128, inf128, b128, inf128, c128, FE_INVALID)
26 BINOP (206, *, a32, 0.df, b32, __builtin_infd32(), c32, FE_INVALID)
27 BINOP (207, *, a32, __builtin_infd32(), b32, 0.df, c32, FE_INVALID)
28 BINOP (208, *, a64, 0.df, b64, __builtin_infd64(), c64, FE_INVALID)
29 BINOP (209, *, a64, __builtin_infd64(), b64, 0.df, c64, FE_INVALID)
30 BINOP (210, *, a128, 0.df, b128, __builtin_infd128(), c128, FE_INVALID)
31 BINOP (211, *, a128, __builtin_infd128(), b128, 0.df, c128, FE_INVALID)
32 BINOP (212, +, a32, inf32, b32, -inf32, c32, FE_INVALID)
33 BINOP (213, +, a64, inf64, b64, -inf64, c64, FE_INVALID)
34 BINOP (214, +, a128, inf128, b128, -inf128, c128, FE_INVALID)
35 BINOP (215, -, a32, inf32, b32, inf32, c32, FE_INVALID)
36 BINOP (216, -, a64, inf64, b64, inf64, c64, FE_INVALID)
37 BINOP (217, -, a128, inf128, b128, inf128, c128, FE_INVALID)
39 BINOP (300, /, a32, 9.9e94df, b32, 1.e-3df, c32, FE_OVERFLOW|FE_INEXACT)
40 BINOP (301, /, a64, 9.9e382dd, b64, 1.e-3dd, c64, FE_OVERFLOW|FE_INEXACT)
41 BINOP (302, /, a128, 9.9e6142dl, b128, 1.e-3dl, c128, FE_OVERFLOW|FE_INEXACT)
42 BINOP (303, +, a32, 9.9e96df, b32, 1.e96df, c32, FE_OVERFLOW|FE_INEXACT)
43 BINOP (304, +, a64, 9.9e384dd, b64, 1.e384dd, c64, FE_OVERFLOW|FE_INEXACT)
44 BINOP (305, +, a128, 9.9e6144dl, b128, 1.e6144dl, c128, FE_OVERFLOW|FE_INEXACT)
46 BINOP (400, /, a32, 1.e-3df, b32, 9.9e94df, c32, FE_UNDERFLOW|FE_INEXACT)
47 BINOP (401, /, a64, 1.e-3dd, b64, 9.9e382dd, c64, FE_UNDERFLOW|FE_INEXACT)
48 BINOP (402, /, a128, 1.e-3dl, b128, 9.9e6142dl, c128, FE_UNDERFLOW|FE_INEXACT)
49 BINOP (403, *, a32, 1.e-95df, b32, 1.e-7df, c32, FE_UNDERFLOW|FE_INEXACT)
50 BINOP (404, *, a64, 1.e-383dd, b64, 1.e-16dd, c64, FE_UNDERFLOW|FE_INEXACT)
51 BINOP (405, *, a128, 1.e-6143dl, b128, 1.e-34dl, c128, FE_UNDERFLOW|FE_INEXACT)
53 BINOP (500, /, a32, 1.df, b32, 3.df, c32, FE_INEXACT)
54 BINOP (501, /, a64, 1.dd, b64, 3.dd, c64, FE_INEXACT)
55 BINOP (502, /, a128, 1.dl, b128, 3.dl, c128, FE_INEXACT)
57 int
58 main ()
60 inf32 = __builtin_infd32();
61 inf64 = __builtin_infd64();
62 inf128 = __builtin_infd128();
64 binop_100 ();
65 binop_101 ();
66 binop_102 ();
68 binop_200 ();
69 binop_201 ();
70 binop_202 ();
71 binop_203 ();
72 binop_204 ();
73 binop_205 ();
74 binop_206 ();
75 binop_207 ();
76 binop_208 ();
77 binop_209 ();
78 binop_210 ();
79 binop_211 ();
80 binop_212 ();
81 binop_213 ();
82 binop_214 ();
83 binop_215 ();
84 binop_216 ();
85 binop_217 ();
87 binop_300 ();
88 binop_301 ();
89 binop_302 ();
90 binop_303 ();
91 binop_304 ();
92 binop_305 ();
94 binop_400 ();
95 binop_401 ();
96 binop_402 ();
97 binop_403 ();
98 binop_404 ();
99 binop_405 ();
101 binop_500 ();
102 binop_501 ();
103 binop_502 ();
105 if (failcnt != 0)
106 abort ();
107 return 0;