public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR66101
Date: Tue, 12 May 2015 13:42:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1505121524040.18702@zhemvz.fhfr.qr> (raw)


This fixes PR66101.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-05-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/66101
	* tree-ssa-dce.c (remove_dead_stmt): Properly mark loops for
	fixup if we turn a loop exit edge to a fallthru edge.

	* gcc.dg/torture/pr66101.c: New testcase.

Index: gcc/tree-ssa-dce.c
===================================================================
*** gcc/tree-ssa-dce.c	(revision 223044)
--- gcc/tree-ssa-dce.c	(working copy)
*************** remove_dead_stmt (gimple_stmt_iterator *
*** 1149,1155 ****
  	if (e != e2)
  	  {
  	    cfg_altered = true;
!             remove_edge (e2);
  	  }
  	else
  	  ei_next (&ei);
--- 1149,1160 ----
  	if (e != e2)
  	  {
  	    cfg_altered = true;
! 	    /* If we made a BB unconditionally exit a loop then this
! 	       transform alters the set of BBs in the loop.  Schedule
! 	       a fixup.  */
! 	    if (loop_exit_edge_p (bb->loop_father, e))
! 	      loops_state_set (LOOPS_NEED_FIXUP);
! 	    remove_edge (e2);
  	  }
  	else
  	  ei_next (&ei);
Index: gcc/testsuite/gcc.dg/torture/pr66101.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr66101.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr66101.c	(working copy)
***************
*** 0 ****
--- 1,35 ----
+ /* { dg-do compile } */
+ 
+ #include <setjmp.h>
+ 
+ jmp_buf env;
+ 
+ int a, c, d, e;
+ 
+ int
+ bar ()
+ {
+   int b = *(long *) 7 == 5 ? : 0;
+   if (a || a > b)
+     longjmp (env, 0);
+   return 1;
+ }
+ 
+ void
+ foo ()
+ {
+   long f;
+   setjmp (env);
+   for (; d; c++)
+     switch (c)
+ case 0:
+       {
+ 	f = bar () >> 1;
+ 	if (e)
+ 	  goto L;
+ 	if (bar () >> 1)
+ 	  goto L;
+       }
+ L:
+     ;
+ }

                 reply	other threads:[~2015-05-12 13:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.1505121524040.18702@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).