Patch for gcc.dg/compare2.c "case 10"

Zack Weinberg zack@wolery.cumb.org
Fri Aug 4 17:45:00 GMT 2000


On Fri, Aug 04, 2000 at 02:02:18PM -0600, Jeffrey A Law wrote:
> 
>   In message < 20000804125149.I23598@wolery.cumb.org >you write:
>   > On Fri, Aug 04, 2000 at 11:41:35AM -0600, Jeffrey A Law wrote:
>   > >   In message <20000601124759.A7977@wolery.cumb.org>you write:
>   > >   > This patch gets rid of the spurious signed/unsigned warning for
>   > >   > 
>   > >   >   unsigned > ({ signed; 23; });
>   > ...
>   > > Basically OK, except the code to handle CONST_DOUBLEs in 
>   > > rtl_expr_nonnegative_p.
>   > > 
>   > > If you need to move it where you can get at CONST_DOUBLE_HIGH, please do
>   > > so.
>   > 
>   > Wow - I'd forgotten all about this patch.  I'll have to dig it out,
>   > reapply it to my tree, and bootstrap again.
> If it's not obvious to everyone, I'm concentrating on dealing with some
> older patches today :-)

I'd guessed.

I moved the definition of CONST_DOUBLE_HIGH to rtl.h per Geoff's
suggestion.  The patch bootstraps on i386-linux; I'll be checking it
in shortly.  Here's the revised version.

zw

        * tree.c (tree_expr_nonnegative_p): Move to...
        * fold-const.c: ... here.  Also handle BIND_EXPR and RTL_EXPR.
        (rtl_expr_nonnegative_p): New.                                
        * tree.h: Add prototype for rtl_expr_nonnegative_p.

        * real.h (CONST_DOUBLE_LOW, CONST_DOUBLE_HIGH, CONST_DOUBLE_MEM,
        CONST_DOUBLE_CHAIN: Move to...
        * rtl.h: ...here.  Use XCINT/XCEXP.

        * gcc.dg/compare2.c: No longer expected to fail.

===================================================================
Index: fold-const.c
--- fold-const.c	2000/08/02 15:28:44	1.128
+++ fold-const.c	2000/08/05 00:43:44
@@ -7260,3 +7260,54 @@ multiple_of_p (type, top, bottom)
       return 0;
     }
 }
+
+/* Return true if `t' is known to be non-negative.  */
+
+int
+tree_expr_nonnegative_p (t)
+     tree t;
+{
+  switch (TREE_CODE (t))
+    {
+    case INTEGER_CST:
+      return tree_int_cst_sgn (t) >= 0;
+    case COND_EXPR:
+      return tree_expr_nonnegative_p (TREE_OPERAND (t, 1))
+	&& tree_expr_nonnegative_p (TREE_OPERAND (t, 2));
+    case BIND_EXPR:
+      return tree_expr_nonnegative_p (TREE_OPERAND (t, 1));
+    case RTL_EXPR:
+      return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t));
+      
+    default:
+      /* We don't know sign of `t', so be safe and return false.  */
+      return 0;
+    }
+}
+
+/* Return true if `r' is known to be non-negative.
+   Only handles constants at the moment.  */
+
+int
+rtl_expr_nonnegative_p (r)
+     rtx r;
+{
+  switch (GET_CODE (r))
+    {
+    case CONST_INT:
+      return INTVAL (r) >= 0;
+
+    case CONST_DOUBLE:
+      if (GET_MODE (r) == VOIDmode)
+	return CONST_DOUBLE_HIGH (r) >= 0;
+      return 0;
+
+    case SYMBOL_REF:
+    case LABEL_REF:
+      /* These are always nonnegative.  */
+      return 1;
+
+    default:
+      return 0;
+    }
+}
===================================================================
Index: real.h
--- real.h	2000/07/17 21:44:56	1.23
+++ real.h	2000/08/05 00:43:44
@@ -451,23 +451,6 @@ union real_extract 
   HOST_WIDE_INT i[sizeof (REAL_VALUE_TYPE) / sizeof (HOST_WIDE_INT)];
 };
 
-/* For a CONST_DOUBLE:
-   The usual two ints that hold the value.
-   For a DImode, that is all there are;
-    and CONST_DOUBLE_LOW is the low-order word and ..._HIGH the high-order.
-   For a float, the number of ints varies,
-    and CONST_DOUBLE_LOW is the one that should come first *in memory*.
-    So use &CONST_DOUBLE_LOW(r) as the address of an array of ints.  */
-#define CONST_DOUBLE_LOW(r) XWINT (r, 2)
-#define CONST_DOUBLE_HIGH(r) XWINT (r, 3)
-
-/* Link for chain of all CONST_DOUBLEs in use in current function.  */
-#define CONST_DOUBLE_CHAIN(r) X0EXP (r, 1)
-/* The MEM which represents this CONST_DOUBLE's value in memory,
-   or const0_rtx if no MEM has been made for it yet,
-   or cc0_rtx if it is not on the chain.  */
-#define CONST_DOUBLE_MEM(r) XEXP (r, 0)
-
 /* Given a CONST_DOUBLE in FROM, store into TO the value it represents.  */
 /* Function to return a real value (not a tree node)
    from a given integer constant.  */
===================================================================
Index: rtl.h
--- rtl.h	2000/08/02 04:21:27	1.215
+++ rtl.h	2000/08/05 00:43:44
@@ -753,6 +753,23 @@ extern const char * const note_insn_name
 
 #define INTVAL(RTX) XCWINT(RTX, 0, CONST_INT)
 
+/* For a CONST_DOUBLE:
+   The usual two ints that hold the value.
+   For a DImode, that is all there are;
+    and CONST_DOUBLE_LOW is the low-order word and ..._HIGH the high-order.
+   For a float, the number of ints varies,
+    and CONST_DOUBLE_LOW is the one that should come first *in memory*.
+    So use &CONST_DOUBLE_LOW(r) as the address of an array of ints.  */
+#define CONST_DOUBLE_LOW(r) XCWINT (r, 2, CONST_DOUBLE)
+#define CONST_DOUBLE_HIGH(r) XCWINT (r, 3, CONST_DOUBLE)
+
+/* Link for chain of all CONST_DOUBLEs in use in current function.  */
+#define CONST_DOUBLE_CHAIN(r) XCEXP (r, 1, CONST_DOUBLE)
+/* The MEM which represents this CONST_DOUBLE's value in memory,
+   or const0_rtx if no MEM has been made for it yet,
+   or cc0_rtx if it is not on the chain.  */
+#define CONST_DOUBLE_MEM(r) XCEXP (r, 0, CONST_DOUBLE)
+
 /* For a SUBREG rtx, SUBREG_REG extracts the value we want a subreg of.
    SUBREG_WORD extracts the word-number.  */
 
===================================================================
Index: tree.c
--- tree.c	2000/07/12 16:17:15	1.152
+++ tree.c	2000/08/05 00:43:46
@@ -4361,25 +4361,6 @@ tree_int_cst_sgn (t)
     return 1;
 }
 
-/* Return true if `t' is known to be non-negative.  */
-
-int
-tree_expr_nonnegative_p (t)
-     tree t;
-{
-  switch (TREE_CODE (t))
-    {
-    case INTEGER_CST:
-      return tree_int_cst_sgn (t) >= 0;
-    case COND_EXPR:
-      return tree_expr_nonnegative_p (TREE_OPERAND (t, 1))
-	&& tree_expr_nonnegative_p (TREE_OPERAND (t, 2));
-    default:
-      /* We don't know sign of `t', so be safe and return false.  */
-      return 0;
-    }
-}
-
 /* Compare two constructor-element-type constants.  Return 1 if the lists
    are known to be equal; otherwise return 0.  */
 
===================================================================
Index: tree.h
--- tree.h	2000/07/27 15:54:27	1.185
+++ tree.h	2000/08/05 00:43:46
@@ -1925,7 +1925,8 @@ extern int host_integerp		PARAMS ((tree,
 extern HOST_WIDE_INT tree_low_cst	PARAMS ((tree, int));
 extern int tree_int_cst_msb		PARAMS ((tree));
 extern int tree_int_cst_sgn		PARAMS ((tree));
-extern int tree_expr_nonnegative_p		PARAMS ((tree));
+extern int tree_expr_nonnegative_p	PARAMS ((tree));
+extern int rtl_expr_nonnegative_p	PARAMS ((struct rtx_def *));
 extern int index_type_equal		PARAMS ((tree, tree));
 extern tree get_inner_array_type	PARAMS ((tree));
 
===================================================================
Index: testsuite/gcc.dg/compare2.c
--- testsuite/gcc.dg/compare2.c	2000/07/30 23:54:58	1.3
+++ testsuite/gcc.dg/compare2.c	2000/08/05 00:43:47
@@ -26,7 +26,7 @@ void f(int x, unsigned int y)
 
   /* Statement expression.  */
   x > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 9" } */
-  y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" { xfail *-*-* } } */
+  y > ({tf; 64;}); /* { dg-bogus "signed and unsigned" "case 10" } */
 
   /* Statement expression with recursive ?: .  */
   x > ({tf; tf?64:(tf?128:256);}); /* { dg-bogus "signed and unsigned" "case 11" } */
cvs [diff aborted]: no such directory `testsuite/gcc.dg'


More information about the Gcc-patches mailing list