re PR middle-end/81695 (internal compiler error: in size_binop_loc, at fold-const...
authorMarek Polacek <polacek@redhat.com>
Wed, 16 Aug 2017 11:26:41 +0000 (11:26 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 16 Aug 2017 11:26:41 +0000 (11:26 +0000)
PR middle/81695
* fold-const.c (fold_indirect_ref_1): Restore original behavior
regarding size_zero_node.

From-SVN: r251119

gcc/ChangeLog
gcc/fold-const.c

index cea00be..6cd2ea6 100644 (file)
@@ -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
index 5a118ca..0a5b168 100644 (file)
@@ -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);
                }
            }
        }