re PR tree-optimization/81620 (ICE in is_inv_store_elimination_chain, at tree-predcom...
authorBin Cheng <bin.cheng@arm.com>
Tue, 1 Aug 2017 09:17:29 +0000 (09:17 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Tue, 1 Aug 2017 09:17:29 +0000 (09:17 +0000)
PR tree-optimization/81620
* tree-predcom.c (add_ref_to_chain): Don't set has_max_use_after
for store-store chain.

gcc/testsuite
* gcc.dg/tree-ssa/pr81620-1.c: New.
* gcc.dg/tree-ssa/pr81620-2.c: New.

From-SVN: r250763

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr81620-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr81620-2.c [new file with mode: 0644]
gcc/tree-predcom.c

index ee6fcd5..c8ed19d 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-01  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/81620
+       * tree-predcom.c (add_ref_to_chain): Don't set has_max_use_after
+       for store-store chain.
+
 2017-08-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/81588
index 08d649c..e2f695f 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-01  Bin Cheng  <bin.cheng@arm.com>
+
+       PR tree-optimization/81620
+       * gcc.dg/tree-ssa/pr81620-1.c: New.
+       * gcc.dg/tree-ssa/pr81620-2.c: New.
+
 2017-08-01  Dominique d'Humieres  <dominiq@lps.ens.fr>
 
        PR testsuite/53542
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81620-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81620-1.c
new file mode 100644 (file)
index 0000000..f8f2dd8
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-tree-loop-vectorize -fdump-tree-pcom-details" } */
+
+int a[7];
+char b;
+void abort (void);
+
+int main() {
+  b = 4;
+  for (; b; b--) {
+    a[b] = b;
+    a[b + 2] = 1;
+  }
+  if (a[0] != 0 || a[1] != 1 || a[2] != 2
+      || a[3] != 1 || a[4] != 1 || a[5] != 1 || a[6] != 1)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Store-stores chain" 1 "pcom" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81620-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81620-2.c
new file mode 100644 (file)
index 0000000..85a8e35
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-tree-loop-vectorize -fdump-tree-pcom-details" } */
+
+int a[200];
+char b;
+void abort (void);
+
+int main() {
+  int i;
+  b = 100;
+  for (; b; b--) {
+    a[b] = 2;
+    a[b + 2] = 1;
+  }
+
+  if (a[0] != 0 || a[1] != 2 || a[2] != 2)
+    abort ();
+  for (i = 3; i < 103; i++)
+    if (a[i] != 1)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Store-stores chain" 1 "pcom" } } */
index a4011bf..f7a57a4 100644 (file)
@@ -1069,7 +1069,9 @@ add_ref_to_chain (chain_p chain, dref ref)
       chain->has_max_use_after = false;
     }
 
-  if (ref->distance == chain->length
+  /* Don't set the flag for store-store chain since there is no use.  */
+  if (chain->type != CT_STORE_STORE
+      && ref->distance == chain->length
       && ref->pos > root->pos)
     chain->has_max_use_after = true;