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]

Re: c/3752: gcc 3.0: __builtin_constant_p(ptr==ptr), regression


On Sat, Jul 21, 2001 at 07:27:36AM +1000, Kevin Ryde wrote:
> >Description:
> gcc 3 __builtin_constant_p fails to recognise "ptr==ptr" as a
> constant, whereas gcc 2.95.x did.

INTEGRAL_TYPE_P does not include POINTER_TYPE_P.

I guess this worked before by having CSE simplify the code appropriately.
If so, this means we've got a CSE regression somewhere too.  I guess I'll
look for that...

In any case, we should simplify this sort of thing as early as possible.

Tested on i686 linux.


r~


        * fold-const.c (fold): Test vs FLOAT_TYPE_P instead of 
        INTEGRAL_TYPE_P when folding comparisons with operand_equal_p 
        arguments.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.146.2.6
diff -u -p -r1.146.2.6 fold-const.c
--- fold-const.c	2001/04/02 08:32:00	1.146.2.6
+++ fold-const.c	2001/07/23 05:47:42
@@ -6489,7 +6489,7 @@ fold (expr)
 	    case EQ_EXPR:
 	    case GE_EXPR:
 	    case LE_EXPR:
-	      if (INTEGRAL_TYPE_P (TREE_TYPE (arg0)))
+	      if (! FLOAT_TYPE_P (TREE_TYPE (arg0)))
 		return constant_boolean_node (1, type);
 	      code = EQ_EXPR;
 	      TREE_SET_CODE (t, code);
@@ -6497,7 +6497,7 @@ fold (expr)
 
 	    case NE_EXPR:
 	      /* For NE, we can only do this simplification if integer.  */
-	      if (! INTEGRAL_TYPE_P (TREE_TYPE (arg0)))
+	      if (FLOAT_TYPE_P (TREE_TYPE (arg0)))
 		break;
 	      /* ... fall through ...  */
 	    case GT_EXPR:


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