diff options
author | Richard Biener <rguenther@suse.de> | 2019-04-25 11:17:49 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-04-25 11:17:49 +0000 |
commit | a9e6359a90a16479a8558f76e6be2a4835ccd8f6 (patch) | |
tree | bab5c976f92cdc45765211fdfd5ca225f8b19711 | |
parent | f469220df6185dee831686631c570245769887da (diff) | |
download | gcc-a9e6359a90a16479a8558f76e6be2a4835ccd8f6.zip gcc-a9e6359a90a16479a8558f76e6be2a4835ccd8f6.tar.gz gcc-a9e6359a90a16479a8558f76e6be2a4835ccd8f6.tar.bz2 |
re PR tree-optimization/90213 (UBSAN: signed integer overflow: -5621332293356458048 * 8 cannot be represented in type 'long int')
2019-04-24 Richard Biener <rguenther@suse.de>
PR middle-end/90213
* gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
by size and BITS_PER_UNIT on poly-wide-ints.
From-SVN: r270570
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2aeafe1..ce8281f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-24 Richard Biener <rguenther@suse.de> + + PR middle-end/90213 + * gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication + by size and BITS_PER_UNIT on poly-wide-ints. + 2019-04-25 Richard Biener <rguenther@suse.de> PR middle-end/90194 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index a9afc4b..f308180 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -6983,14 +6983,10 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree)) = wi::sext (wi::to_poly_offset (idx) - wi::to_poly_offset (low_bound), TYPE_PRECISION (TREE_TYPE (idx))); - + woffset *= tree_to_uhwi (unit_size); + woffset *= BITS_PER_UNIT; if (woffset.to_shwi (&offset)) { - /* TODO: This code seems wrong, multiply then check - to see if it fits. */ - offset *= tree_to_uhwi (unit_size); - offset *= BITS_PER_UNIT; - base = TREE_OPERAND (t, 0); ctor = get_base_constructor (base, &offset, valueize); /* Empty constructor. Always fold to 0. */ |