diff options
author | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-12 13:19:40 +0000 |
---|---|---|
committer | uweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-12 13:19:40 +0000 |
commit | e2eb2b7f42c984114a733ebf5b9b4fd48c77f52c (patch) | |
tree | 8520ed37f4f8d6016d590082a4aa6d51a73e1cdd /gcc/builtins.c | |
parent | 98bbec1e473511d08a36b0cf5796c7337c5d07f8 (diff) | |
download | gcc-e2eb2b7f42c984114a733ebf5b9b4fd48c77f52c.tar.gz |
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.
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139014 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index a5c55ad0ba7..c062d3a251a 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -12867,14 +12867,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); } @@ -12909,7 +12911,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; @@ -12917,7 +12921,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); } @@ -12955,7 +12959,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; @@ -12964,7 +12970,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); } @@ -12998,7 +13004,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; @@ -13006,7 +13014,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); @@ -13071,14 +13079,17 @@ 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; + tree result_s, result_c; 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); } @@ -13112,7 +13123,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; @@ -13121,7 +13134,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); @@ -13189,7 +13202,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; @@ -13197,7 +13212,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) |