From: Marek Polacek Date: Wed, 16 Aug 2017 11:26:41 +0000 (+0000) Subject: re PR middle-end/81695 (internal compiler error: in size_binop_loc, at fold-const... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5dd2d9850bfe2159c1f71b25c5451eab2c603ec2;p=gcc.git re PR middle-end/81695 (internal compiler error: in size_binop_loc, at fold-const.c:1768) PR middle/81695 * fold-const.c (fold_indirect_ref_1): Restore original behavior regarding size_zero_node. From-SVN: r251119 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cea00bef1fb..6cd2ea6616f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-16 Marek Polacek + + PR middle/81695 + * fold-const.c (fold_indirect_ref_1): Restore original behavior + regarding size_zero_node. + 2017-08-16 Martin Liska PR target/81753 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5a118ca50a1..0a5b168c320 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); } } }