This patch removes more explicit sizetype references by (but not only by) introducing convert_to_ptrofftype[_loc]. It's still trivial conversions so even with the no-op abstraction we can be sure to not introduce new errors.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2011-08-17 Richard Guenther <rguent...@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. Index: trunk/gcc/builtins.c =================================================================== *** trunk.orig/gcc/builtins.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/builtins.c 2011-08-17 12:35:56.000000000 +0200 *************** expand_builtin_bzero (tree exp) *** 3631,3637 **** calling bzero instead of memset. */ return expand_builtin_memset_args (dest, integer_zero_node, ! fold_convert_loc (loc, sizetype, size), const0_rtx, VOIDmode, exp); } --- 3631,3638 ---- calling bzero instead of memset. */ return expand_builtin_memset_args (dest, integer_zero_node, ! fold_convert_loc (loc, ! size_type_node, size), const0_rtx, VOIDmode, exp); } *************** std_gimplify_va_arg_expr (tree valist, t *** 4225,4235 **** 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)))); gimplify_and_add (t, pre_p); } else --- 4226,4235 ---- fold_build_pointer_plus_hwi (valist_tmp, boundary - 1)); gimplify_and_add (t, pre_p); t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp, ! fold_build2 (BIT_AND_EXPR, TREE_TYPE (valist), ! valist_tmp, ! build_int_cst (TREE_TYPE (valist), -boundary))); gimplify_and_add (t, pre_p); } else *************** fold_builtin_bzero (location_t loc, tree *** 7969,7975 **** calling bzero instead of memset. */ return fold_builtin_memset (loc, dest, integer_zero_node, ! fold_convert_loc (loc, sizetype, size), void_type_node, ignore); } --- 7969,7975 ---- calling bzero instead of memset. */ return fold_builtin_memset (loc, dest, integer_zero_node, ! fold_convert_loc (loc, size_type_node, size), void_type_node, ignore); } Index: trunk/gcc/c-typeck.c =================================================================== *** trunk.orig/gcc/c-typeck.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/c-typeck.c 2011-08-17 10:18:47.000000000 +0200 *************** build_unary_op (location_t location, *** 3652,3658 **** } inc = c_size_in_bytes (TREE_TYPE (argtype)); ! inc = fold_convert_loc (location, sizetype, inc); } else if (FRACT_MODE_P (TYPE_MODE (argtype))) { --- 3652,3658 ---- } inc = c_size_in_bytes (TREE_TYPE (argtype)); ! inc = convert_to_ptrofftype_loc (location, inc); } else if (FRACT_MODE_P (TYPE_MODE (argtype))) { Index: trunk/gcc/cgraphunit.c =================================================================== *** trunk.orig/gcc/cgraphunit.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/cgraphunit.c 2011-08-17 12:20:32.000000000 +0200 *************** thunk_adjust (gimple_stmt_iterator * bsi *** 1478,1484 **** tree vtabletmp; tree vtabletmp2; tree vtabletmp3; - tree offsettmp; if (!vtable_entry_type) { --- 1478,1483 ---- *************** thunk_adjust (gimple_stmt_iterator * bsi *** 1527,1541 **** 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); } if (!this_adjusting --- 1526,1535 ---- mark_symbols_for_renaming (stmt); find_referenced_vars_in (stmt); /* Adjust the `this' pointer. */ ! 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 *************** cgraph_redirect_edge_call_stmt_to_callee *** 2417,2424 **** 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)); e->indirect_info->thunk_delta = 0; } --- 2411,2417 ---- gsi = gsi_for_stmt (e->call_stmt); gsi_computed = true; gimple_adjust_this_by_delta (&gsi, ! size_int (e->indirect_info->thunk_delta)); e->indirect_info->thunk_delta = 0; } Index: trunk/gcc/expr.c =================================================================== *** trunk.orig/gcc/expr.c 2011-08-17 10:17:51.000000000 +0200 --- trunk/gcc/expr.c 2011-08-17 10:44:16.000000000 +0200 *************** expand_expr_addr_expr_1 (tree exp, rtx t *** 7231,7239 **** { 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))); return expand_expr (tem, target, tmode, modifier); } --- 7231,7237 ---- { tree tem = TREE_OPERAND (exp, 0); if (!integer_zerop (TREE_OPERAND (exp, 1))) ! tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1)); return expand_expr (tem, target, tmode, modifier); } Index: trunk/gcc/fold-const.c =================================================================== *** trunk.orig/gcc/fold-const.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/fold-const.c 2011-08-17 10:51:21.000000000 +0200 *************** build_range_check (location_t loc, tree *** 4218,4225 **** { if (value != 0 && !TREE_OVERFLOW (value)) { ! low = fold_convert_loc (loc, sizetype, low); ! low = fold_build1_loc (loc, NEGATE_EXPR, sizetype, low); return build_range_check (loc, type, fold_build_pointer_plus_loc (loc, exp, low), 1, build_int_cst (etype, 0), value); --- 4218,4224 ---- { if (value != 0 && !TREE_OVERFLOW (value)) { ! 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); *************** fold_unary_loc (location_t loc, enum tre *** 7862,7871 **** 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)); } /* Convert (T1)(~(T2)X) into ~(T1)X if T1 and T2 are integral types --- 7861,7868 ---- tree arg00 = TREE_OPERAND (arg0, 0); tree arg01 = TREE_OPERAND (arg0, 1); ! 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 Index: trunk/gcc/gimple-fold.c =================================================================== *** trunk.orig/gcc/gimple-fold.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/gimple-fold.c 2011-08-17 10:52:04.000000000 +0200 *************** gimple_adjust_this_by_delta (gimple_stmt *** 1436,1442 **** tree parm, tmp; gimple new_stmt; ! delta = fold_convert (sizetype, 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))); --- 1436,1442 ---- tree parm, tmp; gimple new_stmt; ! 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))); Index: trunk/gcc/gimplify.c =================================================================== *** trunk.orig/gcc/gimplify.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/gimplify.c 2011-08-17 10:18:47.000000000 +0200 *************** gimplify_self_mod_expr (tree *expr_p, gi *** 2208,2214 **** /* For POINTERs increment, use POINTER_PLUS_EXPR. */ if (POINTER_TYPE_P (TREE_TYPE (lhs))) { ! rhs = fold_convert_loc (loc, sizetype, rhs); if (arith_code == MINUS_EXPR) rhs = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (rhs), rhs); arith_code = POINTER_PLUS_EXPR; --- 2208,2214 ---- /* For POINTERs increment, use POINTER_PLUS_EXPR. */ if (POINTER_TYPE_P (TREE_TYPE (lhs))) { ! 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; Index: trunk/gcc/graphite-clast-to-gimple.c =================================================================== *** trunk.orig/gcc/graphite-clast-to-gimple.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/graphite-clast-to-gimple.c 2011-08-17 10:55:18.000000000 +0200 *************** clast_to_gcc_expression (tree type, stru *** 346,352 **** 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 = fold_convert (type, name); return name; --- 346,352 ---- tree name = clast_name_to_gcc (t->var, ip); if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) ! name = convert_to_ptrofftype (name); name = fold_convert (type, name); return name; *************** clast_to_gcc_expression (tree type, stru *** 357,363 **** 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 = fold_convert (type, name); --- 357,363 ---- tree name = clast_name_to_gcc (t->var, ip); if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) ! name = convert_to_ptrofftype (name); name = fold_convert (type, name); *************** clast_to_gcc_expression (tree type, stru *** 369,375 **** 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 = fold_convert (type, name); --- 369,375 ---- tree cst = gmp_cst_to_tree (type, t->val); if (POINTER_TYPE_P (TREE_TYPE (name)) != POINTER_TYPE_P (type)) ! name = convert_to_ptrofftype (name); name = fold_convert (type, name); *************** graphite_create_new_loop_guard (edge ent *** 1064,1070 **** else { tree one = (POINTER_TYPE_P (*type) ! ? size_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 --- 1064,1070 ---- else { tree one = (POINTER_TYPE_P (*type) ! ? 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 Index: trunk/gcc/graphite-sese-to-poly.c =================================================================== *** trunk.orig/gcc/graphite-sese-to-poly.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/graphite-sese-to-poly.c 2011-08-17 10:18:47.000000000 +0200 *************** rewrite_commutative_reductions_out_of_ss *** 3219,3227 **** } } - /* 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. */ --- 3219,3224 ---- *************** scop_ivs_can_be_represented (scop_p scop *** 3246,3252 **** tree type = TREE_TYPE (res); if (TYPE_UNSIGNED (type) ! && TYPE_PRECISION (type) >= TYPE_PRECISION (my_long_long)) return false; } } --- 3243,3249 ---- tree type = TREE_TYPE (res); if (TYPE_UNSIGNED (type) ! && TYPE_PRECISION (type) >= TYPE_PRECISION (long_long_integer_type_node)) return false; } } *************** scop_ivs_can_be_represented (scop_p scop *** 3254,3261 **** return true; } - #undef my_long_long - /* Builds the polyhedral representation for a SESE region. */ void --- 3251,3256 ---- Index: trunk/gcc/tree-cfg.c =================================================================== *** trunk.orig/gcc/tree-cfg.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-cfg.c 2011-08-17 10:18:47.000000000 +0200 *************** verify_gimple_assign_unary (gimple stmt) *** 3329,3345 **** { /* 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 of pointers we need to allow arbitrary conversions from and ! to sizetype. */ if ((POINTER_TYPE_P (lhs_type) && INTEGRAL_TYPE_P (rhs1_type) && (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type) ! || rhs1_type == sizetype)) || (POINTER_TYPE_P (rhs1_type) && INTEGRAL_TYPE_P (lhs_type) && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type) ! || lhs_type == sizetype))) return false; /* Allow conversion from integer to offset type and vice versa. */ --- 3329,3345 ---- { /* Allow conversions between integral types and pointers only if there is no sign or zero extension involved. ! For targets were the precision of ptrofftype doesn't match that of pointers we need to allow arbitrary conversions from and ! to ptrofftype. */ if ((POINTER_TYPE_P (lhs_type) && INTEGRAL_TYPE_P (rhs1_type) && (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type) ! || ptrofftype_p (rhs1_type))) || (POINTER_TYPE_P (rhs1_type) && INTEGRAL_TYPE_P (lhs_type) && (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type) ! || ptrofftype_p (sizetype)))) return false; /* Allow conversion from integer to offset type and vice versa. */ Index: trunk/gcc/tree-chrec.c =================================================================== *** trunk.orig/gcc/tree-chrec.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-chrec.c 2011-08-17 11:01:02.000000000 +0200 *************** static tree *** 262,269 **** 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); --- 262,267 ---- *************** chrec_fold_plus_1 (enum tree_code code, *** 327,335 **** && 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)); else return chrec_dont_know; } --- 325,339 ---- && size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE)) return build2 (code, type, op0, op1); else if (size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE)) ! { ! 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; } Index: trunk/gcc/tree-loop-distribution.c =================================================================== *** trunk.orig/gcc/tree-loop-distribution.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-loop-distribution.c 2011-08-17 13:46:05.000000000 +0200 *************** build_size_arg_loc (location_t loc, tree *** 242,250 **** 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))); x = force_gimple_operand (x, &stmts, true, NULL); gimple_seq_add_seq (stmt_list, stmts); --- 242,251 ---- gimple_seq *stmt_list) { gimple_seq stmts; ! 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); *************** generate_memset_zero (gimple stmt, tree *** 275,283 **** 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))))) { addr_base = size_binop_loc (loc, MINUS_EXPR, addr_base, fold_convert_loc (loc, sizetype, nb_bytes)); --- 276,282 ---- addr_base = fold_convert_loc (loc, sizetype, addr_base); /* Test for a negative stride, iterating over every element. */ ! 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)); Index: trunk/gcc/tree-mudflap.c =================================================================== *** trunk.orig/gcc/tree-mudflap.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-mudflap.c 2011-08-17 10:18:47.000000000 +0200 *************** mf_xform_derefs_1 (gimple_stmt_iterator *** 851,857 **** limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type, fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, ! convert (mf_uintptr_type, addr), size), integer_one_node); } --- 851,857 ---- limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type, fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, ! fold_convert (mf_uintptr_type, addr), size), integer_one_node); } *************** mf_xform_derefs_1 (gimple_stmt_iterator *** 897,916 **** return; bpu = bitsize_int (BITS_PER_UNIT); ! ofs = 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)); ! size = 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); addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0); ! addr = convert (ptr_type_node, addr); addr = fold_build_pointer_plus_loc (location, addr, ofs); base = addr; --- 897,913 ---- return; bpu = bitsize_int (BITS_PER_UNIT); ! ofs = fold_convert (bitsizetype, TREE_OPERAND (t, 2)); rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu); ! ofs = size_binop_loc (location, TRUNC_DIV_EXPR, ofs, bpu); ! 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 = fold_convert (sizetype, size); addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0); ! addr = fold_convert (ptr_type_node, addr); addr = fold_build_pointer_plus_loc (location, addr, ofs); base = addr; *************** mx_register_decls (tree decl, gimple_seq *** 1049,1055 **** /* Variable-sized objects should have sizes already been gimplified when we got here. */ ! size = convert (size_type_node, TYPE_SIZE_UNIT (TREE_TYPE (decl))); gcc_assert (is_gimple_val (size)); --- 1046,1053 ---- /* Variable-sized objects should have sizes already been gimplified when we got here. */ ! size = fold_convert (size_type_node, ! TYPE_SIZE_UNIT (TREE_TYPE (decl))); gcc_assert (is_gimple_val (size)); *************** mudflap_register_call (tree obj, tree ob *** 1233,1243 **** tree arg, call_stmt; arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj); ! arg = convert (ptr_type_node, arg); call_stmt = build_call_expr (mf_register_fndecl, 4, arg, ! convert (size_type_node, object_size), /* __MF_TYPE_STATIC */ build_int_cst (integer_type_node, 4), varname); --- 1231,1241 ---- tree arg, call_stmt; arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (obj)), obj); ! arg = fold_convert (ptr_type_node, arg); call_stmt = build_call_expr (mf_register_fndecl, 4, arg, ! fold_convert (size_type_node, object_size), /* __MF_TYPE_STATIC */ build_int_cst (integer_type_node, 4), varname); Index: trunk/gcc/tree-predcom.c =================================================================== *** trunk.orig/gcc/tree-predcom.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-predcom.c 2011-08-17 10:18:47.000000000 +0200 *************** suitable_reference_p (struct data_refere *** 618,628 **** static void aff_combination_dr_offset (struct data_reference *dr, aff_tree *offset) { aff_tree delta; ! tree_to_aff_combination_expand (DR_OFFSET (dr), sizetype, offset, &name_expansions); ! aff_combination_const (&delta, sizetype, tree_to_double_int (DR_INIT (dr))); aff_combination_add (offset, &delta); } --- 618,629 ---- 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), type, offset, &name_expansions); ! aff_combination_const (&delta, type, tree_to_double_int (DR_INIT (dr))); aff_combination_add (offset, &delta); } *************** determine_offset (struct data_reference *** 667,673 **** aff_combination_scale (&baseb, double_int_minus_one); aff_combination_add (&diff, &baseb); ! tree_to_aff_combination_expand (DR_STEP (a), sizetype, &step, &name_expansions); return aff_combination_constant_multiple_p (&diff, &step, off); } --- 668,674 ---- aff_combination_scale (&baseb, double_int_minus_one); aff_combination_add (&diff, &baseb); ! 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); } *************** valid_initializer_p (struct data_referen *** 1050,1057 **** 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); if (!aff_combination_constant_multiple_p (&diff, &step, &off)) return false; --- 1051,1058 ---- aff_combination_scale (&base, double_int_minus_one); aff_combination_add (&diff, &base); ! 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; Index: trunk/gcc/tree-profile.c =================================================================== *** trunk.orig/gcc/tree-profile.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-profile.c 2011-08-17 10:18:47.000000000 +0200 *************** prepare_instrumented_value (gimple_stmt_ *** 241,247 **** { tree val = value->hvalue.value; if (POINTER_TYPE_P (TREE_TYPE (val))) ! val = fold_convert (sizetype, val); return force_gimple_operand_gsi (gsi, fold_convert (gcov_type_node, val), true, NULL_TREE, true, GSI_SAME_STMT); } --- 241,248 ---- { tree val = value->hvalue.value; if (POINTER_TYPE_P (TREE_TYPE (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); } Index: trunk/gcc/tree-scalar-evolution.c =================================================================== *** trunk.orig/gcc/tree-scalar-evolution.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-scalar-evolution.c 2011-08-17 10:18:47.000000000 +0200 *************** interpret_rhs_expr (struct loop *loop, g *** 1727,1733 **** 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); res = chrec_fold_plus (type, chrec1, chrec2); break; --- 1727,1733 ---- chrec1 = analyze_scalar_evolution (loop, rhs1); chrec2 = analyze_scalar_evolution (loop, rhs2); chrec1 = chrec_convert (type, chrec1, at_stmt); ! chrec2 = chrec_convert (TREE_TYPE (rhs2), chrec2, at_stmt); res = chrec_fold_plus (type, chrec1, chrec2); break; Index: trunk/gcc/tree-ssa-address.c =================================================================== *** trunk.orig/gcc/tree-ssa-address.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-ssa-address.c 2011-08-17 12:32:42.000000000 +0200 *************** tree_mem_ref_addr (tree type, tree mem_r *** 279,285 **** if (act_elem) { if (step) ! act_elem = fold_build2 (MULT_EXPR, sizetype, act_elem, step); addr_off = act_elem; } --- 279,286 ---- if (act_elem) { if (step) ! act_elem = fold_build2 (MULT_EXPR, TREE_TYPE (act_elem), ! act_elem, step); addr_off = act_elem; } *************** tree_mem_ref_addr (tree type, tree mem_r *** 287,302 **** if (act_elem) { if (addr_off) ! addr_off = fold_build2 (PLUS_EXPR, sizetype, 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); else addr_off = offset; } --- 288,304 ---- if (act_elem) { if (addr_off) ! addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off), ! addr_off, act_elem); else addr_off = act_elem; } if (offset && !integer_zerop (offset)) { if (addr_off) ! addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off), addr_off, ! fold_convert (TREE_TYPE (addr_off), offset)); else addr_off = offset; } Index: trunk/gcc/tree-ssa-loop-ivopts.c =================================================================== *** trunk.orig/gcc/tree-ssa-loop-ivopts.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-ssa-loop-ivopts.c 2011-08-17 10:18:47.000000000 +0200 *************** find_bivs (struct ivopts_data *data) *** 1035,1041 **** if (step) { if (POINTER_TYPE_P (type)) ! step = fold_convert (sizetype, step); else step = fold_convert (type, step); } --- 1035,1041 ---- if (step) { if (POINTER_TYPE_P (type)) ! step = convert_to_ptrofftype (step); else step = fold_convert (type, step); } Index: trunk/gcc/tree-ssa-loop-manip.c =================================================================== *** trunk.orig/gcc/tree-ssa-loop-manip.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-ssa-loop-manip.c 2011-08-17 10:18:47.000000000 +0200 *************** create_iv (tree base, tree step, tree va *** 100,108 **** { if (TREE_CODE (base) == ADDR_EXPR) mark_addressable (TREE_OPERAND (base, 0)); ! step = fold_convert (sizetype, step); if (incr_op == MINUS_EXPR) ! step = fold_build1 (NEGATE_EXPR, sizetype, step); incr_op = POINTER_PLUS_EXPR; } /* Gimplify the step if necessary. We put the computations in front of the --- 100,108 ---- { if (TREE_CODE (base) == ADDR_EXPR) mark_addressable (TREE_OPERAND (base, 0)); ! step = convert_to_ptrofftype (step); if (incr_op == MINUS_EXPR) ! 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 *************** determine_exit_conditions (struct loop * *** 705,711 **** enum tree_code cmp = desc->cmp; tree cond = boolean_true_node, assum; ! /* For pointers, do the arithmetics in the type of step (sizetype). */ base = fold_convert (type, base); bound = fold_convert (type, bound); --- 705,711 ---- enum tree_code cmp = desc->cmp; tree cond = boolean_true_node, assum; ! /* For pointers, do the arithmetics in the type of step. */ base = fold_convert (type, base); bound = fold_convert (type, bound); Index: trunk/gcc/tree-ssa-pre.c =================================================================== *** trunk.orig/gcc/tree-ssa-pre.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-ssa-pre.c 2011-08-17 10:18:47.000000000 +0200 *************** create_expression_by_pieces (basic_block *** 3099,3110 **** stmts, domstmt); if (!genop1 || !genop2) return NULL_TREE; ! /* Ensure op2 is a sizetype 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); } else { --- 3099,3110 ---- stmts, domstmt); if (!genop1 || !genop2) return NULL_TREE; ! /* 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 = convert_to_ptrofftype (genop2); } else { Index: trunk/gcc/tree-ssa-structalias.c =================================================================== *** trunk.orig/gcc/tree-ssa-structalias.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/tree-ssa-structalias.c 2011-08-17 13:56:33.000000000 +0200 *************** get_constraint_for_1 (tree t, VEC (ce_s, *** 3260,3266 **** { struct constraint_expr cs; varinfo_t vi, curr; ! tree off = double_int_to_tree (sizetype, mem_ref_offset (t)); get_constraint_for_ptr_offset (TREE_OPERAND (t, 0), off, results); do_deref (results); --- 3260,3266 ---- { struct constraint_expr cs; varinfo_t vi, curr; ! tree off = convert_to_ptrofftype (TREE_OPERAND (t, 1)); get_constraint_for_ptr_offset (TREE_OPERAND (t, 0), off, results); do_deref (results); Index: trunk/gcc/varasm.c =================================================================== *** trunk.orig/gcc/varasm.c 2011-08-17 10:17:49.000000000 +0200 --- trunk/gcc/varasm.c 2011-08-17 12:33:22.000000000 +0200 *************** output_constant (tree exp, unsigned HOST *** 4628,4636 **** static unsigned HOST_WIDE_INT array_size_for_constructor (tree val) { ! tree max_index, i; unsigned HOST_WIDE_INT cnt; tree index, value, tmp; /* 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 --- 4628,4637 ---- static unsigned HOST_WIDE_INT array_size_for_constructor (tree val) { ! 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 *************** array_size_for_constructor (tree val) *** 4652,4665 **** /* 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); /* 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)))); ! return tree_low_cst (i, 1); } /* Other datastructures + helpers for output_constructor. */ --- 4653,4667 ---- /* Compute the total number of array elements. */ tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val))); ! 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 = double_int_mul (i, tree_to_double_int ! (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))))); ! gcc_assert (double_int_fits_in_uhwi_p (i)); ! return i.low; } /* Other datastructures + helpers for output_constructor. */ Index: trunk/gcc/tree.h =================================================================== *** trunk.orig/gcc/tree.h 2011-08-17 10:17:51.000000000 +0200 --- trunk/gcc/tree.h 2011-08-17 10:19:58.000000000 +0200 *************** ptrofftype_p (tree type) *** 5323,5328 **** --- 5323,5337 ---- && 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)