Commit 4aaa3351 by Richard Sandiford Committed by Richard Sandiford

tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed overflow.

gcc/
	* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed
	overflow.  Use tree_to_shwi.

From-SVN: r205102
parent 51935318
2013-11-20 Richard Sandiford <rdsandiford@googlemail.com> 2013-11-20 Richard Sandiford <rdsandiford@googlemail.com>
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed
overflow. Use tree_to_shwi.
2013-11-20 Richard Sandiford <rdsandiford@googlemail.com>
* fold-const.c (fold_binary_loc): Use unsigned rather than signed * fold-const.c (fold_binary_loc): Use unsigned rather than signed
HOST_WIDE_INTs when folding (x >> c) << c. HOST_WIDE_INTs when folding (x >> c) << c.
...@@ -578,7 +578,7 @@ ao_ref_alias_set (ao_ref *ref) ...@@ -578,7 +578,7 @@ ao_ref_alias_set (ao_ref *ref)
void void
ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
{ {
HOST_WIDE_INT t, extra_offset = 0; HOST_WIDE_INT t, size_hwi, extra_offset = 0;
ref->ref = NULL_TREE; ref->ref = NULL_TREE;
if (TREE_CODE (ptr) == SSA_NAME) if (TREE_CODE (ptr) == SSA_NAME)
{ {
...@@ -617,9 +617,8 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ...@@ -617,9 +617,8 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
ref->offset += extra_offset; ref->offset += extra_offset;
if (size if (size
&& tree_fits_shwi_p (size) && tree_fits_shwi_p (size)
&& TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT && (size_hwi = tree_to_shwi (size)) <= HOST_WIDE_INT_MAX / BITS_PER_UNIT)
== TREE_INT_CST_LOW (size)) ref->max_size = ref->size = size_hwi * BITS_PER_UNIT;
ref->max_size = ref->size = TREE_INT_CST_LOW (size) * BITS_PER_UNIT;
else else
ref->max_size = ref->size = -1; ref->max_size = ref->size = -1;
ref->ref_alias_set = 0; ref->ref_alias_set = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment