diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2008-08-19 16:37:13 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@gcc.gnu.org> | 2008-08-19 16:37:13 +0000 |
commit | 38c29cbea3de335f5d0af1e2175285ab4c73815b (patch) | |
tree | c67fff0f7a950f385fe763c43912160fcfcd1aa9 /gcc/builtins.c | |
parent | 6157a1313a08463103b544ec8c6c3107b9bd2925 (diff) |
real.h (struct real_format): New member round_towards_zero.prereleases/gcc-4.3.2-rc1
ChangeLog:
* real.h (struct real_format): New member round_towards_zero.
* real.c (round_for_format): Respect fmt->round_towards_zero.
(ieee_single_format, mips_single_format, motorola_single_format,
spu_single_format, ieee_double_format, mips_double_format,
motorola_double_format, ieee_extended_motorola_format,
ieee_extended_intel_96_format, ieee_extended_intel_128_format,
ieee_extended_intel_96_round_53_format, ibm_extended_format,
mips_extended_format, ieee_quad_format, mips_quad_format,
vax_f_format, vax_d_format, vax_g_format): Initialize it.
* config/pdp11/pdp11.c (pdp11_f_format, pdp11_d_format): Likewise.
* builtins.s (do_mpfr_arg1): Consider round_towards_zero member of
real_format to choose rounding mode when calling MPFR functions.
(do_mpfr_arg2, do_mpfr_arg3, do_mpfr_sincos): Likewise.
(do_mpfr_bessel_n, do_mpfr_remquo, do_mpfr_lgamma_r): Likewise.
* real.h (real_to_decimal_for_mode): Add prototype.
* real.c (real_to_decimal_for_mode): Renames old real_to_decimal.
Respect target rounding mode when generating decimal representation.
(real_to_decimal): New stub for backwards compatibility.
* c-cppbuiltin.c (builtin_define_with_hex_fp_value): Use
real_to_decimal_for_mode instead of real_to_decimal.
* config/spu/spu.md ("floatdisf2", "floatunsdisf2"): New.
* config/spu/float_disf.c: New file.
* config/spu/float_unsdisf.c: New file.
* config/spu/t-elf (LIB2FUNCS_STATIC_EXTRA): Add them.
(LIB2FUNCS_EXCLUDE): Define.
testsuite/ChangeLog:
* gcc.c-torture/execute/20031003-1.c (main): Update test to
accommodate SPU single-precision rounding mode.
* gcc.c-torture/execute/conversion.c (test_float_to_integer,
test_float_to_longlong_integer): Likewise.
* gcc.c-torture/execute/ieee/rbug.c (main): Likewise.
* gcc.dg/hex-round-1.c: Skip test on SPU.
* gcc.dg/hex-round-2.c: Likewise.
* gcc.dg/torture/fp-int-convert-float.c: Reenable test on SPU.
* gcc.dg/torture/fp-int-convert-timode.c: Reenable "float" test on SPU.
From-SVN: r139240
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 66d55733fe7..d61651e7728 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -12688,14 +12688,16 @@ do_mpfr_arg1 (tree arg, tree type, int (*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t), && (!min || real_compare (inclusive ? GE_EXPR: GT_EXPR , ra, min)) && (!max || real_compare (inclusive ? LE_EXPR: LT_EXPR , ra, max))) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; int inexact; mpfr_t m; mpfr_init2 (m, prec); mpfr_from_real (m, ra, GMP_RNDN); mpfr_clear_flags (); - inexact = func (m, m, GMP_RNDN); + inexact = func (m, m, rnd); result = do_mpfr_ckconv (m, type, inexact); mpfr_clear (m); } @@ -12730,7 +12732,9 @@ do_mpfr_arg2 (tree arg1, tree arg2, tree type, if (real_isfinite (ra1) && real_isfinite (ra2)) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; int inexact; mpfr_t m1, m2; @@ -12738,7 +12742,7 @@ do_mpfr_arg2 (tree arg1, tree arg2, tree type, mpfr_from_real (m1, ra1, GMP_RNDN); mpfr_from_real (m2, ra2, GMP_RNDN); mpfr_clear_flags (); - inexact = func (m1, m1, m2, GMP_RNDN); + inexact = func (m1, m1, m2, rnd); result = do_mpfr_ckconv (m1, type, inexact); mpfr_clears (m1, m2, NULL); } @@ -12776,7 +12780,9 @@ do_mpfr_arg3 (tree arg1, tree arg2, tree arg3, tree type, if (real_isfinite (ra1) && real_isfinite (ra2) && real_isfinite (ra3)) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; int inexact; mpfr_t m1, m2, m3; @@ -12785,7 +12791,7 @@ do_mpfr_arg3 (tree arg1, tree arg2, tree arg3, tree type, mpfr_from_real (m2, ra2, GMP_RNDN); mpfr_from_real (m3, ra3, GMP_RNDN); mpfr_clear_flags (); - inexact = func (m1, m1, m2, m3, GMP_RNDN); + inexact = func (m1, m1, m2, m3, rnd); result = do_mpfr_ckconv (m1, type, inexact); mpfr_clears (m1, m2, m3, NULL); } @@ -12819,7 +12825,9 @@ do_mpfr_sincos (tree arg, tree arg_sinp, tree arg_cosp) if (real_isfinite (ra)) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; tree result_s, result_c; int inexact; mpfr_t m, ms, mc; @@ -12827,7 +12835,7 @@ do_mpfr_sincos (tree arg, tree arg_sinp, tree arg_cosp) mpfr_inits2 (prec, m, ms, mc, NULL); mpfr_from_real (m, ra, GMP_RNDN); mpfr_clear_flags (); - inexact = mpfr_sin_cos (ms, mc, m, GMP_RNDN); + inexact = mpfr_sin_cos (ms, mc, m, rnd); result_s = do_mpfr_ckconv (ms, type, inexact); result_c = do_mpfr_ckconv (mc, type, inexact); mpfr_clears (m, ms, mc, NULL); @@ -12892,14 +12900,16 @@ do_mpfr_bessel_n (tree arg1, tree arg2, tree type, && real_isfinite (ra) && (!min || real_compare (inclusive ? GE_EXPR: GT_EXPR , ra, min))) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; int inexact; mpfr_t m; mpfr_init2 (m, prec); mpfr_from_real (m, ra, GMP_RNDN); mpfr_clear_flags (); - inexact = func (m, n, m, GMP_RNDN); + inexact = func (m, n, m, rnd); result = do_mpfr_ckconv (m, type, inexact); mpfr_clear (m); } @@ -12933,7 +12943,9 @@ do_mpfr_remquo (tree arg0, tree arg1, tree arg_quo) if (real_isfinite (ra0) && real_isfinite (ra1)) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; tree result_rem; long integer_quo; mpfr_t m0, m1; @@ -12942,7 +12954,7 @@ do_mpfr_remquo (tree arg0, tree arg1, tree arg_quo) mpfr_from_real (m0, ra0, GMP_RNDN); mpfr_from_real (m1, ra1, GMP_RNDN); mpfr_clear_flags (); - mpfr_remquo (m0, &integer_quo, m0, m1, GMP_RNDN); + mpfr_remquo (m0, &integer_quo, m0, m1, rnd); /* Remquo is independent of the rounding mode, so pass inexact=0 to do_mpfr_ckconv(). */ result_rem = do_mpfr_ckconv (m0, type, /*inexact=*/ 0); @@ -13010,7 +13022,9 @@ do_mpfr_lgamma_r (tree arg, tree arg_sg, tree type) && ra->cl != rvc_zero && !(real_isneg(ra) && real_isinteger(ra, TYPE_MODE (type)))) { - const int prec = REAL_MODE_FORMAT (TYPE_MODE (type))->p; + const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type)); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN; int inexact, sg; mpfr_t m; tree result_lg; @@ -13018,7 +13032,7 @@ do_mpfr_lgamma_r (tree arg, tree arg_sg, tree type) mpfr_init2 (m, prec); mpfr_from_real (m, ra, GMP_RNDN); mpfr_clear_flags (); - inexact = mpfr_lgamma (m, &sg, m, GMP_RNDN); + inexact = mpfr_lgamma (m, &sg, m, rnd); result_lg = do_mpfr_ckconv (m, type, inexact); mpfr_clear (m); if (result_lg) |