+2011-08-17 Richard Guenther <rguenther@suse.de>
+
+ * tree.h (convert_to_ptrofftype_loc): New function.
+ (convert_to_ptrofftype): Define.
+ * builtins.c (expand_builtin_bzero): Use size_type_node.
+ (fold_builtin_bzero): Likewise.
+ (std_gimplify_va_arg_expr): Build the BIT_AND_EXPR on the pointer.
+ * c-typeck.c (build_unary_op): Use convert_to_ptrofftype_loc.
+ * cgraphunit.c (thunk_adjust): Use fold_build_pointer_plus_loc.
+ (cgraph_redirect_edge_call_stmt_to_callee): Use size_int.
+ * expr.c (expand_expr_addr_expr_1): Use fold_build_pointer_plus.
+ * fold-const.c (build_range_check): Negate using the original
+ type.
+ (fold_unary_loc): Use fold_build_pointer_plus_loc.
+ * gimple-fold.c (gimple_adjust_this_by_delta): Use
+ convert_to_ptrofftype.
+ * gimplify.c (gimplify_self_mod_expr): Likewise.
+ * graphite-clast-to-gimple.c (clast_to_gcc_expression): Likewise.
+ (graphite_create_new_loop_guard): Likewise.
+ * graphite-sese-to-poly.c (my_long_long): Remove.
+ (scop_ivs_can_be_represented): Adjust.
+ * tree-cfg.c (verify_gimple_assign_unary): Use ptrofftype_p.
+ * tree-chrec.c (chrec_fold_plus_1): Use fold_build_pointer_plus.
+ * tree-loop-distribution.c (build_size_arg_loc): Use
+ size_type_node.
+ (generate_memset_zero): Simplify.
+ * tree-mudflap.c: Use fold_convert, not convert.
+ * tree-predcom.c (suitable_reference_p): Expand DR_OFFSET in
+ its own type.
+ (determine_offset): Likewise for DR_STEP.
+ (valid_initializer_p): Likewise.
+ * tree-profile.c (prepare_instrumented_value): Convert the pointer
+ to an integer type of same size.
+ * tree-scalar-evolution.c (interpret_rhs_expr): Do not refer
+ to sizetype without need.
+ * tree-ssa-address.c (tree_mem_ref_addr): Likewise.
+ * tree-ssa-loop-ivopts.c (find_bivs): Use convert_to_ptrofftype.
+ * tree-ssa-loop-manip.c (create_iv): Likewise.
+ (determine_exit_conditions): Adjust comment.
+ * tree-ssa-pre.c (create_expression_by_pieces): Use
+ convert_to_ptrofftype.
+ * tree-ssa-structalias.c (get_constraint_for_1): Likewise.
+ * varasm.c (array_size_for_constructor): Compute using double_ints.
+
2011-08-16 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* config/spu/spu.c (spu_emit_branch_or_set): Avoid reverse tests
calling bzero instead of memset. */
return expand_builtin_memset_args (dest, integer_zero_node,
- fold_convert_loc (loc, sizetype, size),
+ fold_convert_loc (loc,
+ size_type_node, size),
const0_rtx, VOIDmode, exp);
}
fold_build_pointer_plus_hwi (valist_tmp, boundary - 1));
gimplify_and_add (t, pre_p);
- t = fold_convert (sizetype, valist_tmp);
t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
- fold_convert (TREE_TYPE (valist),
- fold_build2 (BIT_AND_EXPR, sizetype, t,
- size_int (-boundary))));
+ fold_build2 (BIT_AND_EXPR, TREE_TYPE (valist),
+ valist_tmp,
+ build_int_cst (TREE_TYPE (valist), -boundary)));
gimplify_and_add (t, pre_p);
}
else
calling bzero instead of memset. */
return fold_builtin_memset (loc, dest, integer_zero_node,
- fold_convert_loc (loc, sizetype, size),
+ fold_convert_loc (loc, size_type_node, size),
void_type_node, ignore);
}
}
inc = c_size_in_bytes (TREE_TYPE (argtype));
- inc = fold_convert_loc (location, sizetype, inc);
+ inc = convert_to_ptrofftype_loc (location, inc);
}
else if (FRACT_MODE_P (TYPE_MODE (argtype)))
{
tree vtabletmp;
tree vtabletmp2;
tree vtabletmp3;
- tree offsettmp;
if (!vtable_entry_type)
{
mark_symbols_for_renaming (stmt);
find_referenced_vars_in (stmt);
- /* Cast to sizetype. */
- offsettmp = create_tmp_var (sizetype, "offset");
- stmt = gimple_build_assign (offsettmp, fold_convert (sizetype, vtabletmp3));
- gsi_insert_after (bsi, stmt, GSI_NEW_STMT);
- mark_symbols_for_renaming (stmt);
- find_referenced_vars_in (stmt);
-
/* Adjust the `this' pointer. */
- ptr = fold_build_pointer_plus_loc (input_location, ptr, offsettmp);
+ ptr = fold_build_pointer_plus_loc (input_location, ptr, vtabletmp3);
+ ptr = force_gimple_operand_gsi (bsi, ptr, true, NULL_TREE, false,
+ GSI_CONTINUE_LINKING);
}
if (!this_adjusting
gsi = gsi_for_stmt (e->call_stmt);
gsi_computed = true;
gimple_adjust_this_by_delta (&gsi,
- build_int_cst (sizetype,
- e->indirect_info->thunk_delta));
+ size_int (e->indirect_info->thunk_delta));
e->indirect_info->thunk_delta = 0;
}
{
tree tem = TREE_OPERAND (exp, 0);
if (!integer_zerop (TREE_OPERAND (exp, 1)))
- tem = build2 (POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)),
- tem,
- double_int_to_tree (sizetype, mem_ref_offset (exp)));
+ tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
return expand_expr (tem, target, tmode, modifier);
}
{
if (value != 0 && !TREE_OVERFLOW (value))
{
- low = fold_convert_loc (loc, sizetype, low);
- low = fold_build1_loc (loc, NEGATE_EXPR, sizetype, low);
+ low = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (low), low);
return build_range_check (loc, type,
fold_build_pointer_plus_loc (loc, exp, low),
1, build_int_cst (etype, 0), value);
tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01 = TREE_OPERAND (arg0, 1);
- return fold_build2_loc (loc,
- TREE_CODE (arg0), type,
- fold_convert_loc (loc, type, arg00),
- fold_convert_loc (loc, sizetype, arg01));
+ return fold_build_pointer_plus_loc
+ (loc, fold_convert_loc (loc, type, arg00), arg01);
}
/* Convert (T1)(~(T2)X) into ~(T1)X if T1 and T2 are integral types
tree parm, tmp;
gimple new_stmt;
- delta = fold_convert (sizetype, delta);
+ delta = convert_to_ptrofftype (delta);
gcc_assert (gimple_call_num_args (call_stmt) >= 1);
parm = gimple_call_arg (call_stmt, 0);
gcc_assert (POINTER_TYPE_P (TREE_TYPE (parm)));
/* For POINTERs increment, use POINTER_PLUS_EXPR. */
if (POINTER_TYPE_P (TREE_TYPE (lhs)))
{
- rhs = fold_convert_loc (loc, sizetype, rhs);
+ rhs = convert_to_ptrofftype_loc (loc, rhs);
if (arith_code == MINUS_EXPR)
rhs = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (rhs), rhs);
arith_code = POINTER_PLUS_EXPR;
tree name = clast_name_to_gcc (t->var, ip);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
- name = fold_convert (sizetype, name);
+ name = convert_to_ptrofftype (name);
name = fold_convert (type, name);
return name;
tree name = clast_name_to_gcc (t->var, ip);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
- name = fold_convert (sizetype, name);
+ name = convert_to_ptrofftype (name);
name = fold_convert (type, name);
tree cst = gmp_cst_to_tree (type, t->val);
if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type))
- name = fold_convert (sizetype, name);
+ name = convert_to_ptrofftype (name);
name = fold_convert (type, name);
else
{
tree one = (POINTER_TYPE_P (*type)
- ? size_one_node
+ ? convert_to_ptrofftype (integer_one_node)
: fold_convert (*type, integer_one_node));
/* Adding +1 and using LT_EXPR helps with loop latches that have a
loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
}
}
-/* Java does not initialize long_long_integer_type_node. */
-#define my_long_long (long_long_integer_type_node ? long_long_integer_type_node : ssizetype)
-
/* Can all ivs be represented by a signed integer?
As CLooG might generate negative values in its expressions, signed loop ivs
are required in the backend. */
tree type = TREE_TYPE (res);
if (TYPE_UNSIGNED (type)
- && TYPE_PRECISION (type) >= TYPE_PRECISION (my_long_long))
+ && TYPE_PRECISION (type) >= TYPE_PRECISION (long_long_integer_type_node))
return false;
}
}
return true;
}
-#undef my_long_long
-
/* Builds the polyhedral representation for a SESE region. */
void
{
/* Allow conversions between integral types and pointers only if
there is no sign or zero extension involved.
- For targets were the precision of sizetype doesn't match that
+ For targets were the precision of ptrofftype doesn't match that
of pointers we need to allow arbitrary conversions from and
- to sizetype. */
+ to ptrofftype. */
if ((POINTER_TYPE_P (lhs_type)
&& INTEGRAL_TYPE_P (rhs1_type)
&& (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type)
- || rhs1_type == sizetype))
+ || ptrofftype_p (rhs1_type)))
|| (POINTER_TYPE_P (rhs1_type)
&& INTEGRAL_TYPE_P (lhs_type)
&& (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)
- || lhs_type == sizetype)))
+ || ptrofftype_p (sizetype))))
return false;
/* Allow conversion from integer to offset type and vice versa. */
chrec_fold_plus_1 (enum tree_code code, tree type,
tree op0, tree op1)
{
- tree op1_type = code == POINTER_PLUS_EXPR ? sizetype : type;
-
if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1))
return chrec_fold_automatically_generated_operands (op0, op1);
&& size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
return build2 (code, type, op0, op1);
else if (size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
- return fold_build2 (code, type,
- fold_convert (type, op0),
- fold_convert (op1_type, op1));
+ {
+ if (code == POINTER_PLUS_EXPR)
+ return fold_build_pointer_plus (fold_convert (type, op0),
+ op1);
+ else
+ return fold_build2 (code, type,
+ fold_convert (type, op0),
+ fold_convert (type, op1));
+ }
else
return chrec_dont_know;
}
gimple_seq *stmt_list)
{
gimple_seq stmts;
- tree x = size_binop_loc (loc, MULT_EXPR,
- fold_convert_loc (loc, sizetype, nb_iter),
- TYPE_SIZE_UNIT (TREE_TYPE (op)));
+ tree x = fold_build2_loc (loc, MULT_EXPR, size_type_node,
+ fold_convert_loc (loc, size_type_node, nb_iter),
+ fold_convert_loc (loc, size_type_node,
+ TYPE_SIZE_UNIT (TREE_TYPE (op))));
x = force_gimple_operand (x, &stmts, true, NULL);
gimple_seq_add_seq (stmt_list, stmts);
addr_base = fold_convert_loc (loc, sizetype, addr_base);
/* Test for a negative stride, iterating over every element. */
- if (integer_zerop (size_binop (PLUS_EXPR,
- TYPE_SIZE_UNIT (TREE_TYPE (op0)),
- fold_convert (sizetype, DR_STEP (dr)))))
+ if (tree_int_cst_sgn (DR_STEP (dr)) == -1)
{
addr_base = size_binop_loc (loc, MINUS_EXPR, addr_base,
fold_convert_loc (loc, sizetype, nb_bytes));
limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type,
fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type,
- convert (mf_uintptr_type, addr),
+ fold_convert (mf_uintptr_type, addr),
size),
integer_one_node);
}
return;
bpu = bitsize_int (BITS_PER_UNIT);
- ofs = convert (bitsizetype, TREE_OPERAND (t, 2));
+ ofs = fold_convert (bitsizetype, TREE_OPERAND (t, 2));
rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu);
- ofs = fold_convert_loc (location,
- sizetype,
- size_binop_loc (location,
- TRUNC_DIV_EXPR, ofs, bpu));
+ ofs = size_binop_loc (location, TRUNC_DIV_EXPR, ofs, bpu);
- size = convert (bitsizetype, TREE_OPERAND (t, 1));
+ size = fold_convert (bitsizetype, TREE_OPERAND (t, 1));
size = size_binop_loc (location, PLUS_EXPR, size, rem);
size = size_binop_loc (location, CEIL_DIV_EXPR, size, bpu);
- size = convert (sizetype, size);
+ size = fold_convert (sizetype, size);
addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
- addr = convert (ptr_type_node, addr);
+ addr = fold_convert (ptr_type_node, addr);
addr = fold_build_pointer_plus_loc (location, addr, ofs);
base = addr;
/* Variable-sized objects should have sizes already been
gimplified when we got here. */
- size = convert (size_type_node, TYPE_SIZE_UNIT (TREE_TYPE (decl)));
+ size = fold_convert (size_type_node,
+ TYPE_SIZE_UNIT (TREE_TYPE (decl)));
gcc_assert (is_gimple_val (size));
tree arg, call_stmt;
arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj);
- arg = convert (ptr_type_node, arg);
+ arg = fold_convert (ptr_type_node, arg);
call_stmt = build_call_expr (mf_register_fndecl, 4,
arg,
- convert (size_type_node, object_size),
+ fold_convert (size_type_node, object_size),
/* __MF_TYPE_STATIC */
build_int_cst (integer_type_node, 4),
varname);
static void
aff_combination_dr_offset (struct data_reference *dr, aff_tree *offset)
{
+ tree type = TREE_TYPE (DR_OFFSET (dr));
aff_tree delta;
- tree_to_aff_combination_expand (DR_OFFSET (dr), sizetype, offset,
+ tree_to_aff_combination_expand (DR_OFFSET (dr), type, offset,
&name_expansions);
- aff_combination_const (&delta, sizetype, tree_to_double_int (DR_INIT (dr)));
+ aff_combination_const (&delta, type, tree_to_double_int (DR_INIT (dr)));
aff_combination_add (offset, &delta);
}
aff_combination_scale (&baseb, double_int_minus_one);
aff_combination_add (&diff, &baseb);
- tree_to_aff_combination_expand (DR_STEP (a), sizetype,
+ tree_to_aff_combination_expand (DR_STEP (a), TREE_TYPE (DR_STEP (a)),
&step, &name_expansions);
return aff_combination_constant_multiple_p (&diff, &step, off);
}
aff_combination_scale (&base, double_int_minus_one);
aff_combination_add (&diff, &base);
- tree_to_aff_combination_expand (DR_STEP (root), sizetype, &step,
- &name_expansions);
+ tree_to_aff_combination_expand (DR_STEP (root), TREE_TYPE (DR_STEP (root)),
+ &step, &name_expansions);
if (!aff_combination_constant_multiple_p (&diff, &step, &off))
return false;
{
tree val = value->hvalue.value;
if (POINTER_TYPE_P (TREE_TYPE (val)))
- val = fold_convert (sizetype, val);
+ val = fold_convert (build_nonstandard_integer_type
+ (TYPE_PRECISION (TREE_TYPE (val)), 1), val);
return force_gimple_operand_gsi (gsi, fold_convert (gcov_type_node, val),
true, NULL_TREE, true, GSI_SAME_STMT);
}
chrec1 = analyze_scalar_evolution (loop, rhs1);
chrec2 = analyze_scalar_evolution (loop, rhs2);
chrec1 = chrec_convert (type, chrec1, at_stmt);
- chrec2 = chrec_convert (sizetype, chrec2, at_stmt);
+ chrec2 = chrec_convert (TREE_TYPE (rhs2), chrec2, at_stmt);
res = chrec_fold_plus (type, chrec1, chrec2);
break;
if (act_elem)
{
if (step)
- act_elem = fold_build2 (MULT_EXPR, sizetype, act_elem, step);
+ act_elem = fold_build2 (MULT_EXPR, TREE_TYPE (act_elem),
+ act_elem, step);
addr_off = act_elem;
}
if (act_elem)
{
if (addr_off)
- addr_off = fold_build2 (PLUS_EXPR, sizetype, addr_off, act_elem);
+ addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off),
+ addr_off, act_elem);
else
addr_off = act_elem;
}
if (offset && !integer_zerop (offset))
{
- offset = fold_convert (sizetype, offset);
if (addr_off)
- addr_off = fold_build2 (PLUS_EXPR, sizetype, addr_off, offset);
+ addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off), addr_off,
+ fold_convert (TREE_TYPE (addr_off), offset));
else
addr_off = offset;
}
if (step)
{
if (POINTER_TYPE_P (type))
- step = fold_convert (sizetype, step);
+ step = convert_to_ptrofftype (step);
else
step = fold_convert (type, step);
}
{
if (TREE_CODE (base) == ADDR_EXPR)
mark_addressable (TREE_OPERAND (base, 0));
- step = fold_convert (sizetype, step);
+ step = convert_to_ptrofftype (step);
if (incr_op == MINUS_EXPR)
- step = fold_build1 (NEGATE_EXPR, sizetype, step);
+ step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
incr_op = POINTER_PLUS_EXPR;
}
/* Gimplify the step if necessary. We put the computations in front of the
enum tree_code cmp = desc->cmp;
tree cond = boolean_true_node, assum;
- /* For pointers, do the arithmetics in the type of step (sizetype). */
+ /* For pointers, do the arithmetics in the type of step. */
base = fold_convert (type, base);
bound = fold_convert (type, bound);
stmts, domstmt);
if (!genop1 || !genop2)
return NULL_TREE;
- /* Ensure op2 is a sizetype for POINTER_PLUS_EXPR. It
+ /* Ensure op2 is a ptrofftype for POINTER_PLUS_EXPR. It
may be a constant with the wrong type. */
if (nary->opcode == POINTER_PLUS_EXPR)
{
genop1 = fold_convert (nary->type, genop1);
- genop2 = fold_convert (sizetype, genop2);
+ genop2 = convert_to_ptrofftype (genop2);
}
else
{
{
struct constraint_expr cs;
varinfo_t vi, curr;
- tree off = double_int_to_tree (sizetype, mem_ref_offset (t));
+ tree off = convert_to_ptrofftype (TREE_OPERAND (t, 1));
get_constraint_for_ptr_offset (TREE_OPERAND (t, 0), off, results);
do_deref (results);
&& TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
}
+/* Return OFF converted to a pointer offset type suitable as offset for
+ POINTER_PLUS_EXPR. Use location LOC for this conversion. */
+static inline tree
+convert_to_ptrofftype_loc (location_t loc, tree off)
+{
+ return fold_convert_loc (loc, sizetype, off);
+}
+#define convert_to_ptrofftype(t) convert_to_ptrofftype_loc (UNKNOWN_LOCATION, t)
+
/* 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)
static unsigned HOST_WIDE_INT
array_size_for_constructor (tree val)
{
- tree max_index, i;
+ tree max_index;
unsigned HOST_WIDE_INT cnt;
tree index, value, tmp;
+ double_int i;
/* This code used to attempt to handle string constants that are not
arrays of single-bytes, but nothing else does, so there's no point in
/* Compute the total number of array elements. */
tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)));
- i = size_binop (MINUS_EXPR, fold_convert (sizetype, max_index),
- fold_convert (sizetype, tmp));
- i = size_binop (PLUS_EXPR, i, size_one_node);
+ i = double_int_sub (tree_to_double_int (max_index), tree_to_double_int (tmp));
+ i = double_int_add (i, double_int_one);
/* Multiply by the array element unit size to find number of bytes. */
- i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
+ i = double_int_mul (i, tree_to_double_int
+ (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val)))));
- return tree_low_cst (i, 1);
+ gcc_assert (double_int_fits_in_uhwi_p (i));
+ return i.low;
}
/* Other datastructures + helpers for output_constructor. */