OSDN Git Service

2007-07-20 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jul 2007 18:10:57 +0000 (18:10 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jul 2007 18:10:57 +0000 (18:10 +0000)
* tree-cfg.c (verify_expr): COND_EXPRs can have any
integral typed condition.
* tree-ssa.c (useless_type_conversion_p): Do not preserve
booleanness.  Only preserve conversions from a non-base
type to a base type, not in general between types with
different TYPE_MIN_VALUE or TYPE_MAX_VALUE.
* tree.def (COND_EXPR): Document that the condition
can be of any integral type.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126804 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-ssa.c
gcc/tree.def

index ba96d76..9dbaf38 100644 (file)
@@ -1,3 +1,14 @@
+2007-07-20  Richard Guenther  <rguenther@suse.de>
+
+       * tree-cfg.c (verify_expr): COND_EXPRs can have any
+       integral typed condition.
+       * tree-ssa.c (useless_type_conversion_p): Do not preserve
+       booleanness.  Only preserve conversions from a non-base
+       type to a base type, not in general between types with
+       different TYPE_MIN_VALUE or TYPE_MAX_VALUE.
+       * tree.def (COND_EXPR): Document that the condition
+       can be of any integral type.
+
 2007-07-20  Nigel Stephens  <nigel@mips.com>
            Richard Sandiford  <richard@codesourcery.com>
 
index 09fe7eb..889e7d7 100644 (file)
@@ -3201,9 +3201,9 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
 
     case COND_EXPR:
       x = COND_EXPR_COND (t);
-      if (TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE)
+      if (!INTEGRAL_TYPE_P (TREE_TYPE (x)))
        {
-         error ("non-boolean used in condition");
+         error ("non-integral used in condition");
          return x;
        }
       if (!is_gimple_condexpr (x))
index db16f23..858745e 100644 (file)
@@ -940,23 +940,18 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
          || TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
        return false;
 
-      /* Preserve booleanness.  Some code assumes an invariant that boolean
-        types stay boolean and do not become 1-bit bit-field types.  */
-      if ((TREE_CODE (inner_type) == BOOLEAN_TYPE)
-         != (TREE_CODE (outer_type) == BOOLEAN_TYPE))
+      /* Conversions from a non-base to a base type are not useless.
+        This way we preserve the invariant to do arithmetic in
+        base types only.  */
+      if (TREE_TYPE (inner_type)
+         && TREE_TYPE (inner_type) != inner_type
+         && (TREE_TYPE (outer_type) == outer_type
+             || TREE_TYPE (outer_type) == NULL_TREE))
        return false;
 
-      /* Preserve changes in the types minimum or maximum value.
-        ???  Due to the way we handle sizetype as signed we need
-        to jump through hoops here to make sizetype and size_type_node
-        compatible.  */
-      if (!tree_int_cst_equal (fold_convert (outer_type,
-                                            TYPE_MIN_VALUE (inner_type)),
-                              TYPE_MIN_VALUE (outer_type))
-         || !tree_int_cst_equal (fold_convert (outer_type,
-                                               TYPE_MAX_VALUE (inner_type)),
-                                 TYPE_MAX_VALUE (outer_type)))
-       return false;
+      /* We don't need to preserve changes in the types minimum or
+        maximum value in general as these do not generate code
+        unless the types precisions are different.  */
 
       return true;
     }
index fc9408a..3b7750a 100644 (file)
@@ -485,7 +485,8 @@ DEFTREECODE (TARGET_EXPR, "target_expr", tcc_expression, 4)
    Operand 0 may be of any type.
    Operand 1 must have the same type as the entire expression, unless
    it unconditionally throws an exception, in which case it should
-   have VOID_TYPE.  The same constraints apply to operand 2.  */
+   have VOID_TYPE.  The same constraints apply to operand 2.  The
+   condition in operand 0 must be of integral type.  */
 DEFTREECODE (COND_EXPR, "cond_expr", tcc_expression, 3)
 
 /* Vector conditional expression. It is like COND_EXPR, but with