aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-05-30 06:31:47 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-05-30 06:31:47 +0000
commit6e246559b842b9fc561f5ce6eefa08912dd4f7fd (patch)
tree34d36011aa1f1b4d6e8fba4506d1fcf929336859 /gcc/expr.c
parentbb3976df48aecf734211898d6d954dc8ebed0713 (diff)
downloadgcc-6e246559b842b9fc561f5ce6eefa08912dd4f7fd.zip
gcc-6e246559b842b9fc561f5ce6eefa08912dd4f7fd.tar.gz
gcc-6e246559b842b9fc561f5ce6eefa08912dd4f7fd.tar.bz2
Use poly_int tree accessors
This patch generalises various places that used hwi tree accessors so that they can handle poly_ints instead. In many cases these changes are by inspection rather than because something had shown them to be necessary. I think the alias.c part is a minor bug fix: previously we used fits_uhwi_p for a signed HOST_WIDE_INT (which the caller does treat as signed rather than unsigned). We also checked whether each individual offset overflowed but didn't check whether the sum did. 2018-05-30 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * alias.c (adjust_offset_for_component_ref): Use poly_int_tree_p and wi::to_poly_offset. Add the current offset and then check whether the sum fits, rather than using an unchecked addition of a checked term. Check for a shwi rather than a uhwi. * expr.c (get_bit_range): Use tree_to_poly_uint64. (store_constructor): Use poly_int_tree_p. (expand_expr_real_1): Likewise. * function.c (assign_temp): Likewise. * fold-const.c (const_binop): Use poly_int_tree_p and wi::to_poly_offset. (fold_indirect_ref_1): Likewise. Use multiple_p to attempt an exact division. * ipa-icf-gimple.c (func_checker::compare_operand): Use to_poly_offset for MEM offsets. * ipa-icf.c (sem_variable::equals): Likewise. * stor-layout.c (compute_record_mode): Use poly_int_tree_p. * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Use wi::to_poly_offset for BIT_FIELD_REF offsets. (vn_reference_maybe_forwprop_address): Use poly_int_tree_p and wi::to_poly_offset. * var-tracking.c (emit_note_insn_var_location): Use tree_to_poly_uint64. From-SVN: r260914
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 51fbc32..1fa3227 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4913,7 +4913,7 @@ get_bit_range (poly_uint64_pod *bitstart, poly_uint64_pod *bitend, tree exp,
else
*bitstart = *bitpos - bitoffset;
- *bitend = *bitstart + tree_to_uhwi (DECL_SIZE (repr)) - 1;
+ *bitend = *bitstart + tree_to_poly_uint64 (DECL_SIZE (repr)) - 1;
}
/* Returns true if ADDR is an ADDR_EXPR of a DECL that does not reside
@@ -6521,12 +6521,10 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
continue;
mode = TYPE_MODE (elttype);
- if (mode == BLKmode)
- bitsize = (tree_fits_uhwi_p (TYPE_SIZE (elttype))
- ? tree_to_uhwi (TYPE_SIZE (elttype))
- : -1);
- else
+ if (mode != BLKmode)
bitsize = GET_MODE_BITSIZE (mode);
+ else if (!poly_int_tree_p (TYPE_SIZE (elttype), &bitsize))
+ bitsize = -1;
if (index != NULL_TREE && TREE_CODE (index) == RANGE_EXPR)
{
@@ -10249,11 +10247,11 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
{
poly_int64 offset = mem_ref_offset (exp).force_shwi ();
base = TREE_OPERAND (base, 0);
+ poly_uint64 type_size;
if (known_eq (offset, 0)
&& !reverse
- && tree_fits_uhwi_p (TYPE_SIZE (type))
- && known_eq (GET_MODE_BITSIZE (DECL_MODE (base)),
- tree_to_uhwi (TYPE_SIZE (type))))
+ && poly_int_tree_p (TYPE_SIZE (type), &type_size)
+ && known_eq (GET_MODE_BITSIZE (DECL_MODE (base)), type_size))
return expand_expr (build1 (VIEW_CONVERT_EXPR, type, base),
target, tmode, modifier);
if (TYPE_MODE (type) == BLKmode)