From 5dd2d9850bfe2159c1f71b25c5451eab2c603ec2 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 16 Aug 2017 11:26:41 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 6 ++++++ 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 + + 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 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); } } } -- 2.7.4