public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4627] tree-optimization/102893 - properly DCE empty loops inside infinite loops
@ 2021-10-22 11:43 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-10-22 11:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c2a9a98a369528c8689ecb68db576f8e7dc2fa45

commit r12-4627-gc2a9a98a369528c8689ecb68db576f8e7dc2fa45
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Oct 22 12:45:32 2021 +0200

    tree-optimization/102893 - properly DCE empty loops inside infinite loops
    
    The following fixes the test for an exit edge I put in place for
    the fix for PR45178 where I somehow misunderstood how the cyclic
    list works.
    
    2021-10-22  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/102893
            * tree-ssa-dce.c (find_obviously_necessary_stmts): Fix the
            test for an exit edge.
    
            * gcc.dg/tree-ssa/ssa-dce-9.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-9.c | 10 ++++++++++
 gcc/tree-ssa-dce.c                        |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-9.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-9.c
new file mode 100644
index 00000000000..e1ffa7f038d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dce-9.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-cddce1" } */
+
+int main()
+{
+  while(1)
+    for(int i=0; i<9000000; i++){}
+}
+
+/* { dg-final { scan-tree-dump-not "if" "cddce1" } } */
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index c4907af923c..372e0691ae6 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -436,7 +436,7 @@ find_obviously_necessary_stmts (bool aggressive)
 
       for (auto loop : loops_list (cfun, 0))
 	/* For loops without an exit do not mark any condition.  */
-	if (loop->exits->next && !finite_loop_p (loop))
+	if (loop->exits->next->e && !finite_loop_p (loop))
 	  {
 	    if (dump_file)
 	      fprintf (dump_file, "cannot prove finiteness of loop %i\n",


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-22 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 11:43 [gcc r12-4627] tree-optimization/102893 - properly DCE empty loops inside infinite loops Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).