OSDN Git Service

* alias.c (find_base_term, case ZERO_EXTEND, case SIGN_EXTEND):
[pf3gnuchains/gcc-fork.git] / gcc / fold-const.c
index edf934d..2f0d4ac 100644 (file)
@@ -1,6 +1,6 @@
 /* Fold a constant sub-tree into a single node for C-compiler
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -1170,13 +1170,7 @@ real_hex_to_f (s, mode)
     {
       if (ISXDIGIT (c))
        {
-         k = c & CHARMASK;
-         if (k >= 'a' && k <= 'f')
-           k = k - 'a' + 10;
-         else if (k >= 'A')
-           k = k - 'A' + 10;
-         else
-           k = k - '0';
+         k = hex_value (c & CHARMASK);
 
          if ((high & 0xf0000000) == 0)
            {
@@ -1388,7 +1382,7 @@ negate_expr (t)
       break;
     }
 
-  return convert (type, build1 (NEGATE_EXPR, TREE_TYPE (t), t));
+  return convert (type, fold (build1 (NEGATE_EXPR, TREE_TYPE (t), t)));
 }
 \f
 /* Split a tree IN into a constant, literal and variable parts that could be
@@ -3117,7 +3111,7 @@ optimize_bit_field_compare (code, compare_type, lhs, rhs)
                                        convert (unsigned_type, rhs),
                                        size_int (lbitsize), 0)))
        {
-         warning ("comparison is always %d due to width of bitfield",
+         warning ("comparison is always %d due to width of bit-field",
                   code == NE_EXPR);
          return convert (compare_type,
                          (code == NE_EXPR
@@ -3130,7 +3124,7 @@ optimize_bit_field_compare (code, compare_type, lhs, rhs)
                              size_int (lbitsize - 1), 0);
       if (! integer_zerop (tem) && ! integer_all_onesp (tem))
        {
-         warning ("comparison is always %d due to width of bitfield",
+         warning ("comparison is always %d due to width of bit-field",
                   code == NE_EXPR);
          return convert (compare_type,
                          (code == NE_EXPR
@@ -6709,7 +6703,7 @@ fold (expr)
                }
 
            else if (TREE_INT_CST_HIGH (arg1) == -1
-                    && (TREE_INT_CST_LOW (arg1)
+                    && (TREE_INT_CST_LOW (arg1)
                         == ((unsigned HOST_WIDE_INT) 1 << (width - 1)))
                     && ! TREE_UNSIGNED (TREE_TYPE (arg1)))
              switch (TREE_CODE (t))
@@ -6735,12 +6729,11 @@ fold (expr)
                }
 
            else if (TREE_INT_CST_HIGH (arg1) == 0
-                     && (TREE_INT_CST_LOW (arg1)
-                         == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 1)
-                     && TREE_UNSIGNED (TREE_TYPE (arg1))
-                        /* signed_type does not work on pointer types.  */
-                     && INTEGRAL_TYPE_P (TREE_TYPE (arg1)))
-
+                    && (TREE_INT_CST_LOW (arg1)
+                        == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 1)
+                    && TREE_UNSIGNED (TREE_TYPE (arg1))
+                    /* signed_type does not work on pointer types.  */
+                    && INTEGRAL_TYPE_P (TREE_TYPE (arg1)))
              switch (TREE_CODE (t))
                {
                case LE_EXPR:
@@ -6759,6 +6752,32 @@ fold (expr)
                default:
                  break;
                }
+
+            else if (TREE_INT_CST_HIGH (arg1) == 0
+                    && (TREE_INT_CST_LOW (arg1)
+                        == ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 1)
+                    && TREE_UNSIGNED (TREE_TYPE (arg1)))
+              switch (TREE_CODE (t))
+                {
+                case GT_EXPR:
+                  return omit_one_operand (type,
+                                           convert (type, integer_zero_node),
+                                           arg0);
+                case GE_EXPR:
+                  TREE_SET_CODE (t, EQ_EXPR);
+                  break;
+
+                case LE_EXPR:
+                  return omit_one_operand (type,
+                                           convert (type, integer_one_node),
+                                           arg0);
+                case LT_EXPR:
+                  TREE_SET_CODE (t, NE_EXPR);
+                  break;
+
+                default:
+                  break;
+                }
          }
       }