fold-const.c (fold_unary): Don't strip signed nops from ABS_EXPRs.
authorJames A. Morrison <phython@gcc.gnu.org>
Fri, 22 Jul 2005 03:48:00 +0000 (03:48 +0000)
committerJames A. Morrison <phython@gcc.gnu.org>
Fri, 22 Jul 2005 03:48:00 +0000 (03:48 +0000)
2005-07-21  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.

From-SVN: r102269

gcc/ChangeLog
gcc/fold-const.c

index 2699e1212f44e65f7e64b8d5078ed3a92df4ca7a..178432c25e7898d894dfe44bb7cbfa32db5fd019 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-21  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.
+
 2005-07-21  DJ Delorie  <dj@redhat.com>
 
        * toplev.c (warn_deprecated_use): Add warning control to warning
index 20c94efedefefc443bb4a8c3e753620b9d0430d9..9a9ea2246c0f5dd511090ed94e80cea958b5fe0e 100644 (file)
@@ -6524,9 +6524,11 @@ fold_unary (enum tree_code code, tree type, tree op0)
   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
@@ -10686,6 +10688,9 @@ multiple_of_p (tree type, tree top, tree bottom)
 int
 tree_expr_nonnegative_p (tree t)
 {
+  if (TYPE_UNSIGNED (TREE_TYPE (t)))
+    return 1;
+
   switch (TREE_CODE (t))
     {
     case ABS_EXPR: