public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "paolo.carlini at oracle dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57994] Constant folding of infinity Date: Thu, 24 Oct 2013 13:01:00 -0000 [thread overview] Message-ID: <bug-57994-4-AXUqOCUgRm@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-57994-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57994 --- Comment #19 from Paolo Carlini <paolo.carlini at oracle dot com> --- If I change fold_builtin_logarithm to pass a true as last argument to do_mpfr_arg1 (thus 0 is accepted) and do_mpfr_ckconv to accept a folded result which is infinity, things finally work. Patchlet below. Note however, that I also need -O1 otherwise, at -O0, we don't try to propagate the constant num and mpfr isn't used, we again have a library call which returns -nan. Index: builtins.c =================================================================== --- builtins.c (revision 204005) +++ builtins.c (working copy) @@ -8191,7 +8191,7 @@ fold_builtin_logarithm (location_t loc, tree fndec const enum built_in_function fcode = builtin_mathfn_code (arg); /* Calculate the result when the argument is a constant. */ - if ((res = do_mpfr_arg1 (arg, type, func, &dconst0, NULL, false))) + if ((res = do_mpfr_arg1 (arg, type, func, &dconst0, NULL, true))) return res; /* Special case, optimize logN(expN(x)) = x. */ @@ -13527,7 +13527,7 @@ do_mpfr_ckconv (mpfr_srcptr m, tree type, int inex /* Proceed iff we get a normal number, i.e. not NaN or Inf and no overflow/underflow occurred. If -frounding-math, proceed iff the result of calling FUNC was exact. */ - if (mpfr_number_p (m) && !mpfr_overflow_p () && !mpfr_underflow_p () + if (!mpfr_nan_p (m) && !mpfr_overflow_p () && !mpfr_underflow_p () && (!flag_rounding_math || !inexact)) { REAL_VALUE_TYPE rr; @@ -13537,7 +13537,7 @@ do_mpfr_ckconv (mpfr_srcptr m, tree type, int inex check for overflow/underflow. If the REAL_VALUE_TYPE is zero but the mpft_t is not, then we underflowed in the conversion. */ - if (real_isfinite (&rr) + if (!real_isnan (&rr) && (rr.cl == rvc_zero) == (mpfr_zero_p (m) != 0)) { REAL_VALUE_TYPE rmode; @@ -13623,7 +13623,7 @@ do_mpfr_arg1 (tree arg, tree type, int (*func)(mpf { const REAL_VALUE_TYPE *const ra = &TREE_REAL_CST (arg); - if (real_isfinite (ra) + if (!real_isnan (ra) && (!min || real_compare (inclusive ? GE_EXPR: GT_EXPR , ra, min)) && (!max || real_compare (inclusive ? LE_EXPR: LT_EXPR , ra, max))) {
next prev parent reply other threads:[~2013-10-24 13:01 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-26 15:13 [Bug tree-optimization/57994] New: " glisse at gcc dot gnu.org 2013-07-26 15:16 ` [Bug tree-optimization/57994] " paolo.carlini at oracle dot com 2013-07-26 21:53 ` joseph at codesourcery dot com 2013-07-27 0:15 ` paolo.carlini at oracle dot com 2013-07-27 19:53 ` paolo.carlini at oracle dot com 2013-07-27 20:10 ` glisse at gcc dot gnu.org 2013-07-27 20:10 ` joseph at codesourcery dot com 2013-07-27 20:26 ` paolo.carlini at oracle dot com 2013-07-27 20:31 ` glisse at gcc dot gnu.org 2013-07-27 20:46 ` paolo.carlini at oracle dot com 2013-07-28 16:38 ` joseph at codesourcery dot com 2013-07-28 17:40 ` vincent-gcc at vinc17 dot net 2013-08-01 20:55 ` vincent-gcc at vinc17 dot net 2013-08-02 23:23 ` paolo.carlini at oracle dot com 2013-08-27 17:34 ` vincent-gcc at vinc17 dot net 2013-10-24 12:27 ` paolo.carlini at oracle dot com 2013-10-24 12:35 ` paolo.carlini at oracle dot com 2013-10-24 12:40 ` paolo.carlini at oracle dot com 2013-10-24 13:01 ` paolo.carlini at oracle dot com [this message] 2013-10-24 13:08 ` paolo.carlini at oracle dot com 2013-10-24 15:29 ` vincent-gcc at vinc17 dot net 2013-10-24 15:42 ` vincent-gcc at vinc17 dot net 2013-10-24 15:51 ` paolo.carlini at oracle dot com 2014-04-22 11:36 ` jakub at gcc dot gnu.org 2014-07-16 13:29 ` jakub at gcc dot gnu.org 2014-10-30 10:43 ` jakub at gcc dot gnu.org 2015-06-26 20:07 ` jakub at gcc dot gnu.org 2015-06-26 20:35 ` jakub at gcc dot gnu.org 2015-06-26 21:20 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-57994-4-AXUqOCUgRm@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).