re PR tree-optimization/87110 ([9 Regresssion] tree check fail in to_wide, at tree...
authorJeff Law <law@redhat.com>
Tue, 28 Aug 2018 04:02:11 +0000 (22:02 -0600)
committerJeff Law <law@gcc.gnu.org>
Tue, 28 Aug 2018 04:02:11 +0000 (22:02 -0600)
PR tree-optimization/87110
* tree-ssa-dse.c (compute_trims): Handle non-constant
TYPE_SIZE_UNIT.

PR tree-optimization/87110
* gcc.c-torture/compile/pr87110.c: New test.

From-SVN: r263906

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr87110.c [new file with mode: 0644]
gcc/tree-ssa-dse.c

index 4cbea7a195dd7219a1487099da9751a06b5e52c1..a85530438877319752db7221521adc04a9aefa3f 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-27  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/87110
+       * tree-ssa-dse.c (compute_trims): Handle non-constant
+       TYPE_SIZE_UNIT.
+
 2018-08-27  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/86914
index 4b5c1533c33453fdbe1bc3a74d1c02fa07f8866b..6d85561ef839e747dcccb99e90e079bb9c25800e 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-27  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/87110
+       * gcc.c-torture/compile/pr87110.c: New test.
+
 2018-08-27  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/86914
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr87110.c b/gcc/testsuite/gcc.c-torture/compile/pr87110.c
new file mode 100644 (file)
index 0000000..8428d3d
--- /dev/null
@@ -0,0 +1,13 @@
+enum a { b, c };
+struct d {
+  _Bool e;
+  enum a f
+};
+g, h;
+i() {
+  struct d j[h];
+  j[0] = (struct d){.f = c};
+  for (; g;)
+    (struct d){};
+}
+
index bddbbe8377a8fa80ad9929805551cce14eb05f51..8b7aea0e54ee2a636866254142bd29d3a2c376f6 100644 (file)
@@ -250,9 +250,13 @@ compute_trims (ao_ref *ref, sbitmap live, int *trim_head, int *trim_tail,
       *trim_tail = last_orig - last_live;
 
       /* But don't trim away out of bounds accesses, as this defeats
-        proper warnings.  */
+        proper warnings.
+
+        We could have a type with no TYPE_SIZE_UNIT or we could have a VLA
+        where TYPE_SIZE_UNIT is not a constant.  */
       if (*trim_tail
          && TYPE_SIZE_UNIT (TREE_TYPE (ref->base))
+         && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (ref->base))) == INTEGER_CST
          && compare_tree_int (TYPE_SIZE_UNIT (TREE_TYPE (ref->base)),
                               last_orig) <= 0)
        *trim_tail = 0;