This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR66101


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:
+     ;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]