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]

[patch] unsigned types are always nonnegative.


 Hi,

  This patch has tree_expr_nonnegative_p return true for unsigned types.
This chunk of the patch in fold_unary is to fix 950612-1.c if only the
tree_expr_nonnegative_p chunk is applied.  Bootstrapped and regtested on
ia64-linux (and x86-linux earlier this month).  Ok for mainline?

-- 
Thanks,
Jim

http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim


2005-07-19  James A. Morrison  <phython@gcc.gnu.org>

	* fold-const.c (fold_unary): Don't strip signed nops from ABS_EXPRs.
	(tree_expr_nonnegative_p): Return try for TYPE_UNSIGNED.

Index: fold-const.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.605
diff -u -p -r1.605 fold-const.c
--- fold-const.c	20 Jul 2005 03:30:47 -0000	1.605
+++ fold-const.c	20 Jul 2005 03:57:17 -0000
@@ -6525,9 +6525,11 @@ fold_unary (enum tree_code code, tree ty
   arg0 = op0;
   if (arg0)
     {
-      if (code == NOP_EXPR || code == FLOAT_EXPR || code == CONVERT_EXPR)
+      if (code == NOP_EXPR || code == CONVERT_EXPR
+	  || code == FLOAT_EXPR || code == ABS_EXPR)
 	{
-	  /* Don't use STRIP_NOPS, because signedness of argument type matters.  */
+	  /* Don't use STRIP_NOPS, because signedness of argument type
+	     matters.  */
 	  STRIP_SIGN_NOPS (arg0);
 	}
       else
@@ -10525,6 +10527,9 @@ multiple_of_p (tree type, tree top, tree
 int
 tree_expr_nonnegative_p (tree t)
 {
+  if (TYPE_UNSIGNED (TREE_TYPE (t)))
+    return 1;
+
   switch (TREE_CODE (t))
     {
     case ABS_EXPR:

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