This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix folding of logb (-Inf) (PR tree-optimization/57066)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 25 Apr 2013 17:31:29 +0200
- Subject: Re: [PATCH] Fix folding of logb (-Inf) (PR tree-optimization/57066)
- References: <20130425132350 dot GM13346 at redhat dot com> <CAFiYyc2jt-7thEySNnzRmcXLYUQt2_xu8rZnBxX4at71geMMHg at mail dot gmail dot com> <20130425151630 dot GO13346 at redhat dot com> <20130425152448 dot GP13346 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 25, 2013 at 05:24:48PM +0200, Marek Polacek wrote:
> On Thu, Apr 25, 2013 at 05:16:31PM +0200, Marek Polacek wrote:
> > Okay, patch updated. Ok now (which branches, all active?)?
> > Regtested/bootstrapped again on x86_64-linux.
>
> Eh, I've found a bug in previous version (not properly adjusted
> testcase). So this one should be ok.
>
> 2013-04-25 Marek Polacek <polacek@redhat.com>
>
> * builtins.c (fold_builtin_logb): Return +Inf for -Inf.
>
> * gcc.dg/torture/builtin-logb-1.c: Adjust testcase.
>
> --- gcc/builtins.c.mp 2013-04-25 12:52:37.463451032 +0200
> +++ gcc/builtins.c 2013-04-25 16:29:59.054615841 +0200
> @@ -9698,7 +9698,16 @@ fold_builtin_logb (location_t loc, tree
> case rvc_inf:
> /* If arg is Inf or NaN and we're logb, return it. */
> if (TREE_CODE (rettype) == REAL_TYPE)
> - return fold_convert_loc (loc, rettype, arg);
> + {
> + /* For logb(-Inf) we have to return +Inf. */
> + if (value->cl == rvc_inf && !tree_expr_nonnegative_p (arg))
Why not
if (value->cl == rvc_inf && value->sign)
or
if (real_isinf (value) && real_isneg (value))
instead?
Jakub