+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
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 */
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);
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));
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));
/* 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));
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;
|| 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)