[PATCH] frexp can be negative(!?)

Richard Guenther rguenther@suse.de
Tue Aug 2 12:26:00 GMT 2005


If what has been found by inspection and what contradicts every
manual page I read about frexp is true (it can return negative
values for negative arguments), then the following patch is
obvious and fixes PR23195.  A safe patch, if we cannot reach
consensus about wether it can return negative numbers, is to
just remove the case.

Should apply to both mainline and 4.0.

Comments?

Richard.


2005-08-02  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/23195
	* fold-const.c (tree_expr_nonnegative_p): frexp(x, &e) is
	positive if its first argument is positive.


Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.613
diff -c -3 -p -r1.613 fold-const.c
*** fold-const.c	1 Aug 2005 03:54:46 -0000	1.613
--- fold-const.c	2 Aug 2005 12:21:33 -0000
*************** tree_expr_nonnegative_p (tree t)
*** 10904,10910 ****
  	    CASE_BUILTIN_F (BUILT_IN_EXP2)
  	    CASE_BUILTIN_F (BUILT_IN_FABS)
  	    CASE_BUILTIN_F (BUILT_IN_FDIM)
- 	    CASE_BUILTIN_F (BUILT_IN_FREXP)
  	    CASE_BUILTIN_F (BUILT_IN_HYPOT)
  	    CASE_BUILTIN_F (BUILT_IN_POW10)
  	    CASE_BUILTIN_I (BUILT_IN_FFS)
--- 10904,10909 ----
*************** tree_expr_nonnegative_p (tree t)
*** 10928,10933 ****
--- 10927,10933 ----
  	    CASE_BUILTIN_F (BUILT_IN_EXPM1)
  	    CASE_BUILTIN_F (BUILT_IN_FLOOR)
  	    CASE_BUILTIN_F (BUILT_IN_FMOD)
+ 	    CASE_BUILTIN_F (BUILT_IN_FREXP)
  	    CASE_BUILTIN_F (BUILT_IN_LCEIL)
  	    CASE_BUILTIN_F (BUILT_IN_LDEXP)
  	    CASE_BUILTIN_F (BUILT_IN_LFLOOR)



More information about the Gcc-patches mailing list