diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 27 |
2 files changed, 18 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cea00be..6cd2ea6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-16 Marek Polacek <polacek@redhat.com> + + PR middle/81695 + * fold-const.c (fold_indirect_ref_1): Restore original behavior + regarding size_zero_node. + 2017-08-16 Martin Liska <mliska@suse.cz> PR target/81753 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5a118ca..0a5b168 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -14109,22 +14109,19 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0) && type == TREE_TYPE (op00type)) { tree type_domain = TYPE_DOMAIN (op00type); - tree min; - if (type_domain != NULL_TREE - && (min = TYPE_MIN_VALUE (type_domain)) - && TREE_CODE (min) == INTEGER_CST) + tree min = size_zero_node; + if (type_domain && TYPE_MIN_VALUE (type_domain)) + min = TYPE_MIN_VALUE (type_domain); + offset_int off = wi::to_offset (op01); + offset_int el_sz = wi::to_offset (TYPE_SIZE_UNIT (type)); + offset_int remainder; + off = wi::divmod_trunc (off, el_sz, SIGNED, &remainder); + if (remainder == 0 && TREE_CODE (min) == INTEGER_CST) { - offset_int off = wi::to_offset (op01); - offset_int el_sz = wi::to_offset (TYPE_SIZE_UNIT (type)); - offset_int remainder; - off = wi::divmod_trunc (off, el_sz, SIGNED, &remainder); - if (remainder == 0) - { - off = off + wi::to_offset (min); - op01 = wide_int_to_tree (sizetype, off); - return build4_loc (loc, ARRAY_REF, type, op00, op01, - NULL_TREE, NULL_TREE); - } + off = off + wi::to_offset (min); + op01 = wide_int_to_tree (sizetype, off); + return build4_loc (loc, ARRAY_REF, type, op00, op01, + NULL_TREE, NULL_TREE); } } } |