tree.h (convert_to_ptrofftype_loc): New function.

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.

From-SVN: r177828
This commit is contained in:
Richard Guenther 2011-08-17 12:00:35 +00:00 committed by Richard Biener
parent f846d4d940
commit 0d82a1c872
24 changed files with 133 additions and 90 deletions

View File

@ -1,3 +1,47 @@
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

View File

@ -3631,7 +3631,8 @@ expand_builtin_bzero (tree exp)
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);
}
@ -4225,11 +4226,10 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
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
@ -7969,7 +7969,7 @@ fold_builtin_bzero (location_t loc, tree dest, tree size, bool ignore)
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);
}

View File

@ -3652,7 +3652,7 @@ build_unary_op (location_t location,
}
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)))
{

View File

@ -1478,7 +1478,6 @@ thunk_adjust (gimple_stmt_iterator * bsi,
tree vtabletmp;
tree vtabletmp2;
tree vtabletmp3;
tree offsettmp;
if (!vtable_entry_type)
{
@ -1527,15 +1526,10 @@ thunk_adjust (gimple_stmt_iterator * bsi,
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
@ -2417,8 +2411,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
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;
}

View File

@ -7231,9 +7231,7 @@ expand_expr_addr_expr_1 (tree exp, rtx target, enum machine_mode tmode,
{
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);
}

View File

@ -4218,8 +4218,7 @@ build_range_check (location_t loc, tree type, tree exp, int in_p,
{
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);
@ -7862,10 +7861,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
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

View File

@ -1436,7 +1436,7 @@ gimple_adjust_this_by_delta (gimple_stmt_iterator *gsi, tree delta)
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)));

View File

@ -2208,7 +2208,7 @@ gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
/* 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;

View File

@ -346,7 +346,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ivs_params_p ip)
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;
@ -357,7 +357,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ivs_params_p ip)
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);
@ -369,7 +369,7 @@ clast_to_gcc_expression (tree type, struct clast_expr *e, ivs_params_p ip)
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);
@ -1064,7 +1064,7 @@ graphite_create_new_loop_guard (edge entry_edge, struct clast_for *stmt,
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

View File

@ -3219,9 +3219,6 @@ rewrite_commutative_reductions_out_of_ssa (scop_p scop)
}
}
/* 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. */
@ -3246,7 +3243,7 @@ scop_ivs_can_be_represented (scop_p scop)
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;
}
}
@ -3254,8 +3251,6 @@ scop_ivs_can_be_represented (scop_p scop)
return true;
}
#undef my_long_long
/* Builds the polyhedral representation for a SESE region. */
void

View File

@ -3246,17 +3246,17 @@ verify_gimple_assign_unary (gimple stmt)
{
/* 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. */

View File

@ -262,8 +262,6 @@ static tree
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);
@ -327,9 +325,15 @@ chrec_fold_plus_1 (enum tree_code code, tree type,
&& 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;
}

View File

@ -242,9 +242,10 @@ build_size_arg_loc (location_t loc, tree nb_iter, tree op,
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);
@ -275,9 +276,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
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));

View File

@ -851,7 +851,7 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
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);
}
@ -897,20 +897,17 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp,
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;
@ -1049,7 +1046,8 @@ mx_register_decls (tree decl, gimple_seq seq, location_t location)
/* 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));
@ -1233,11 +1231,11 @@ mudflap_register_call (tree obj, tree object_size, tree varname)
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);

View File

@ -618,11 +618,12 @@ suitable_reference_p (struct data_reference *a, enum ref_step_type *ref_step)
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);
}
@ -667,7 +668,7 @@ determine_offset (struct data_reference *a, struct data_reference *b,
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);
}
@ -1050,8 +1051,8 @@ valid_initializer_p (struct data_reference *ref,
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;

View File

@ -241,7 +241,8 @@ prepare_instrumented_value (gimple_stmt_iterator *gsi, histogram_value value)
{
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);
}

View File

@ -1727,7 +1727,7 @@ interpret_rhs_expr (struct loop *loop, gimple at_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;

View File

@ -279,7 +279,8 @@ tree_mem_ref_addr (tree type, tree mem_ref)
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;
}
@ -287,16 +288,17 @@ tree_mem_ref_addr (tree type, tree mem_ref)
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;
}

View File

@ -1035,7 +1035,7 @@ find_bivs (struct ivopts_data *data)
if (step)
{
if (POINTER_TYPE_P (type))
step = fold_convert (sizetype, step);
step = convert_to_ptrofftype (step);
else
step = fold_convert (type, step);
}

View File

@ -100,9 +100,9 @@ create_iv (tree base, tree step, tree var, struct loop *loop,
{
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
@ -705,7 +705,7 @@ determine_exit_conditions (struct loop *loop, struct tree_niter_desc *desc,
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);

View File

@ -3099,12 +3099,12 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
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
{

View File

@ -3260,7 +3260,7 @@ get_constraint_for_1 (tree t, VEC (ce_s, heap) **results, bool address_p,
{
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);

View File

@ -5323,6 +5323,15 @@ ptrofftype_p (tree type)
&& 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)

View File

@ -4628,9 +4628,10 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
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
@ -4652,14 +4653,15 @@ array_size_for_constructor (tree val)
/* 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. */