[GCC12] tree-optimization/99912 - schedule DSE before SRA

Message ID nycvar.YFH.7.76.2104071430570.30527@elmra.sevgm.obk
State New
Headers show
Series
  • [GCC12] tree-optimization/99912 - schedule DSE before SRA
Related show

Commit Message

Richard Biener April 7, 2021, 12:31 p.m.
For the testcase in the PR the main SRA pass is unable to do some
important scalarizations because dead stores of addresses make
the candiate variables disqualified.  The following patch adds
another DSE pass before SRA forming a DCE/DSE pair and moves the
DSE pass that is currently closely after SRA up to after the
next DCE pass, forming another DCE/DSE pair now residing after PRE.

This currently FAILs

FAIL: gfortran.dg/pr81303.f   -O   scan-tree-dump-times linterchange "is interch
anged" 1
FAIL: gfortran.dg/vect/pr81303.f   -O   scan-tree-dump-times linterchange "is in
terchanged" 1

where I filed PR99956 for, loop interchange needs some improvement here.

Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for GCC 12.

2021-04-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99912
	* passes.def (pass_all_optimizations): Add pass_dse before
	the first pass_dce, move the first pass_dse before the
	pass_dce following pass_pre.

	* gcc.dg/tree-ssa/ldist-33.c: Disable PRE and LIM.
	* gcc.dg/tree-ssa/pr96789.c: Adjust dump file scanned.
	* gcc.dg/tree-ssa/ssa-dse-28.c: Likewise.
	* gcc.dg/tree-ssa/ssa-dse-29.c: Likewise.
---
 gcc/passes.def                             | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c   | 5 ++++-
 gcc/testsuite/gcc.dg/tree-ssa/pr96789.c    | 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c | 3 ++-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c | 3 ++-
 5 files changed, 11 insertions(+), 5 deletions(-)

-- 
2.26.2

Patch

diff --git a/gcc/passes.def b/gcc/passes.def
index e9ed3c7bc57..61fe9fdc42c 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -210,6 +210,7 @@  along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_merge_phi);
       NEXT_PASS (pass_thread_jumps);
       NEXT_PASS (pass_vrp, true /* warn_array_bounds_p */);
+      NEXT_PASS (pass_dse);
       NEXT_PASS (pass_dce);
       NEXT_PASS (pass_stdarg);
       NEXT_PASS (pass_call_cdce);
@@ -236,7 +237,6 @@  along with GCC; see the file COPYING3.  If not see
       /* Identify paths that should never be executed in a conforming
 	 program and isolate those paths.  */
       NEXT_PASS (pass_isolate_erroneous_paths);
-      NEXT_PASS (pass_dse);
       NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
       NEXT_PASS (pass_dce);
       NEXT_PASS (pass_forwprop);
@@ -254,6 +254,7 @@  along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_sancov);
       NEXT_PASS (pass_asan);
       NEXT_PASS (pass_tsan);
+      NEXT_PASS (pass_dse);
       NEXT_PASS (pass_dce);
       /* Pass group that runs when 1) enabled, 2) there are loops
 	 in the function.  Make sure to run pass_fix_loops before
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
index 9e0cedf4fa3..67846a5b183 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-33.c
@@ -1,5 +1,8 @@ 
 /* { dg-do compile { target size32plus } } */
-/* { dg-options "-O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
+/* The desire is to show we can generate a memset from the outer loop
+   store.  Both store motion and PRE expose a DSE opportunity for this
+   zeroing - while desirable this defeats the purpose of this testcase.  */
+/* { dg-options "-O2 -fno-tree-loop-im -fno-tree-pre -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
 
 #define N (1024)
 double a[N][N], b[N][N], c[N][N];
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c b/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
index 5704952309b..4d4d4c8ac6f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
@@ -58,4 +58,4 @@  bar (int16_t res[16], uint8_t *val1, uint8_t *val2)
     }
 }
 
-/* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse3" } } */
+/* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse4" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
index b81cabe604a..3bf4e76c965 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
@@ -17,5 +17,6 @@  int foo (int *p, int b)
 
 /* { dg-final { scan-tree-dump-not "Deleted dead store" "dse1"} } */
 /* { dg-final { scan-tree-dump-not "Deleted dead store" "dse2"} } */
-/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse4"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse3"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse5"} } */
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
index f4ef89c590c..4990ae0d18c 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-29.c
@@ -22,5 +22,6 @@  foo(int cond, struct z *s)
 
 /* { dg-final { scan-tree-dump-times "Deleted dead store" 3 "dse1"} } */
 /* { dg-final { scan-tree-dump-not "Deleted dead store" "dse2"} } */
-/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse4"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse3"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse5"} } */