This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Add some folding of builtins fmin/fmax


On Sat, 2006-11-25 at 11:06 -0500, Kaveh R. GHAZI wrote:
> On Sat, 18 Nov 2006, Roger Sayle wrote:
> 
> > I'm sure you've already got it queued, but you can now easily add
> > fmin(x,NaN) -> x and fmin(NaN,y) -> y to your new fold_builtin_fmin_fmax.
> > Roger
> 
> Well I hadn't actually planned on it, but here you go. :-)
> Bootstrapped on sparc-sun-solaris2.10, no regressions.
> 
> Okay for mainline?
> 
> 		Thanks,
> 		--Kaveh
> 
> 
> 2006-11-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
> 
> 	* builtins.c (fold_builtin_fmin_fmax): Handle NaN arguments.
> 
> testsuite:
> 	* gcc.dg/torture/builtin-minmax-1.c: Test NaN in fmin/fmax.
> 
> diff -rup orig/egcc-SVN20061118/gcc/builtins.c egcc-SVN20061118/gcc/builtins.c
> --- orig/egcc-SVN20061118/gcc/builtins.c	2006-11-18 15:52:31.000000000 -0500
> +++ egcc-SVN20061118/gcc/builtins.c	2006-11-18 16:23:42.423868408 -0500
> @@ -8742,6 +8742,13 @@ fold_builtin_fmin_fmax (tree arglist, tr
>        if (res)
>  	return res;
> 
> +      /* If either argument is NaN, return the other one.  */
> +      if (TREE_CODE (arg0) == REAL_CST && real_isnan (&TREE_REAL_CST (arg0)))
> +	return fold_convert (type, arg1);
> +      else
> +	if (TREE_CODE (arg1) == REAL_CST && real_isnan (&TREE_REAL_CST (arg1)))
> +	  return fold_convert (type, arg0);

Shouldn't these be using omit_one_operand?

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]