OSDN Git Service

2011-08-16 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Aug 2011 13:55:30 +0000 (13:55 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Aug 2011 13:55:30 +0000 (13:55 +0000)
* tree.h (ptrofftype_p): New helper function.
* tree-cfg.c (verify_expr): Use ptrofftype_p for POINTER_PLUS_EXPR
offset verification.
(verify_gimple_assign_binary): Likewise.
* tree.c (build2_stat): Likewise.
* tree-chrec.c (chrec_fold_plus_poly_poly): Likewise.
(reset_evolution_in_loop): Likewise.
* tree-chrec.h (build_polynomial_chrec): Likewise.

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

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-chrec.c
gcc/tree-chrec.h
gcc/tree.c
gcc/tree.h

index a2f8a23..7b672d1 100644 (file)
@@ -1,3 +1,14 @@
+2011-08-16  Richard Guenther  <rguenther@suse.de>
+
+       * tree.h (ptrofftype_p): New helper function.
+       * tree-cfg.c (verify_expr): Use ptrofftype_p for POINTER_PLUS_EXPR
+       offset verification.
+       (verify_gimple_assign_binary): Likewise.
+       * tree.c (build2_stat): Likewise.
+       * tree-chrec.c (chrec_fold_plus_poly_poly): Likewise.
+       (reset_evolution_in_loop): Likewise.
+       * tree-chrec.h (build_polynomial_chrec): Likewise.
+
 2011-08-16  Liang Wang  <lwang1@marvell.com>
 
        * ggc.h (ggc_alloc_rtvec_sized): Change arguments of
index 1207908..ea85959 100644 (file)
@@ -2772,13 +2772,11 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
          error ("invalid operand to pointer plus, first operand is not a pointer");
          return t;
        }
-      /* Check to make sure the second operand is an integer with type of
-        sizetype.  */
-      if (!useless_type_conversion_p (sizetype,
-                                    TREE_TYPE (TREE_OPERAND (t, 1))))
+      /* Check to make sure the second operand is a ptrofftype.  */
+      if (!ptrofftype_p (TREE_TYPE (TREE_OPERAND (t, 1))))
        {
          error ("invalid operand to pointer plus, second operand is not an "
-                "integer with type of sizetype");
+                "integer type of appropriate width");
          return t;
        }
       /* FALLTHROUGH */
@@ -3525,7 +3523,7 @@ verify_gimple_assign_binary (gimple stmt)
 do_pointer_plus_expr_check:
        if (!POINTER_TYPE_P (rhs1_type)
            || !useless_type_conversion_p (lhs_type, rhs1_type)
-           || !useless_type_conversion_p (sizetype, rhs2_type))
+           || !ptrofftype_p (rhs2_type))
          {
            error ("type mismatch in pointer plus expression");
            debug_generic_stmt (lhs_type);
index f9bebee..9ceb6f0 100644 (file)
@@ -95,14 +95,14 @@ chrec_fold_plus_poly_poly (enum tree_code code,
   tree left, right;
   struct loop *loop0 = get_chrec_loop (poly0);
   struct loop *loop1 = get_chrec_loop (poly1);
-  tree rtype = code == POINTER_PLUS_EXPR ? sizetype : type;
+  tree rtype = code == POINTER_PLUS_EXPR ? chrec_type (poly1) : type;
 
   gcc_assert (poly0);
   gcc_assert (poly1);
   gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
   gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
   if (POINTER_TYPE_P (chrec_type (poly0)))
-    gcc_assert (chrec_type (poly1) == sizetype);
+    gcc_assert (ptrofftype_p (chrec_type (poly1)));
   else
     gcc_assert (chrec_type (poly0) == chrec_type (poly1));
   gcc_assert (type == chrec_type (poly0));
@@ -831,7 +831,7 @@ reset_evolution_in_loop (unsigned loop_num,
   struct loop *loop = get_loop (loop_num);
 
   if (POINTER_TYPE_P (chrec_type (chrec)))
-    gcc_assert (sizetype == chrec_type (new_evol));
+    gcc_assert (ptrofftype_p (chrec_type (new_evol)));
   else
     gcc_assert (chrec_type (chrec) == chrec_type (new_evol));
 
index 9b971bd..bf9bff0 100644 (file)
@@ -145,7 +145,7 @@ build_polynomial_chrec (unsigned loop_num,
 
   /* Types of left and right sides of a chrec should be compatible.  */
   if (POINTER_TYPE_P (TREE_TYPE (left)))
-    gcc_assert (sizetype == TREE_TYPE (right));
+    gcc_assert (ptrofftype_p (TREE_TYPE (right)));
   else
     gcc_assert (TREE_TYPE (left) == TREE_TYPE (right));
 
index d20751a..3eaf2f9 100644 (file)
@@ -3784,8 +3784,7 @@ build2_stat (enum tree_code code, tree tt, tree arg0, tree arg1 MEM_STAT_DECL)
 
   if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
     gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
-               && INTEGRAL_TYPE_P (TREE_TYPE (arg1))
-               && useless_type_conversion_p (sizetype, TREE_TYPE (arg1)));
+               && ptrofftype_p (TREE_TYPE (arg1)));
 
   t = make_node_stat (code PASS_MEM_STAT);
   TREE_TYPE (t) = tt;
index c8d292a..139c276 100644 (file)
@@ -5313,6 +5313,16 @@ truth_value_p (enum tree_code code)
          || code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR);
 }
 
+/* Return whether TYPE is a type suitable for an offset for
+   a POINTER_PLUS_EXPR.  */
+static inline bool
+ptrofftype_p (tree type)
+{
+  return (INTEGRAL_TYPE_P (type)
+         && TYPE_PRECISION (type) == TYPE_PRECISION (sizetype)
+         && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
+}
+
 /* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF.  */
 static inline tree
 fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off)