aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-08-18 08:33:21 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-08-18 08:33:21 +0000
commit97919ae7b65c192b0fdb6dfa6abdebd63a3f4ba9 (patch)
tree72321f7542701e8f11e627c812fb466857e6393f /gcc/expr.c
parent55715096b51c2cb7e9a9cd03bd562301b7867051 (diff)
downloadgcc-97919ae7b65c192b0fdb6dfa6abdebd63a3f4ba9.zip
gcc-97919ae7b65c192b0fdb6dfa6abdebd63a3f4ba9.tar.gz
gcc-97919ae7b65c192b0fdb6dfa6abdebd63a3f4ba9.tar.bz2
expr.c (get_inner_reference): Sign-extend the constant twos-complement offset before doing arbitrary...
2011-08-18 Richard Guenther <rguenther@suse.de> * expr.c (get_inner_reference): Sign-extend the constant twos-complement offset before doing arbitrary precision arithmetic on it. * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Likewise. (get_constraint_for_1): Pass the offset of a MEM_REF unchanged to get_constraint_for_ptr_offset. From-SVN: r177847
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 98e6cff..6fb82ae 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6502,12 +6502,14 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
/* If OFFSET is constant, see if we can return the whole thing as a
constant bit position. Make sure to handle overflow during
this conversion. */
- if (host_integerp (offset, 0))
- {
- double_int tem = double_int_lshift (tree_to_double_int (offset),
- BITS_PER_UNIT == 8
- ? 3 : exact_log2 (BITS_PER_UNIT),
- HOST_BITS_PER_DOUBLE_INT, true);
+ if (TREE_CODE (offset) == INTEGER_CST)
+ {
+ double_int tem = tree_to_double_int (offset);
+ tem = double_int_sext (tem, TYPE_PRECISION (sizetype));
+ tem = double_int_lshift (tree_to_double_int (offset),
+ BITS_PER_UNIT == 8
+ ? 3 : exact_log2 (BITS_PER_UNIT),
+ HOST_BITS_PER_DOUBLE_INT, true);
tem = double_int_add (tem, bit_offset);
if (double_int_fits_in_shwi_p (tem))
{