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 PR57081


This should fix PR57081 - the problem is that number-of-iteration
estimates are not freed by DCE and thus possibly dead stmts are looked
at in loop prediction.  The fix is to always free number-of-iteration
estimates at loop_optimizer_finalize time (this is the behavior
from before preserving loops at all).

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-04-26  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/57081
	* loop-init.c: Include tree-flow.h.
	(loop_optimizer_finalize): Free number of iteration estimates.
	* Makefile.in (loop-init.o): Add $(TREE_FLOW_H) dependency.

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

Index: gcc/loop-init.c
===================================================================
*** gcc/loop-init.c	(revision 198334)
--- gcc/loop-init.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 30,35 ****
--- 30,36 ----
  #include "flags.h"
  #include "df.h"
  #include "ggc.h"
+ #include "tree-flow.h"
  
  
  /* Apply FLAGS to the loop state.  */
*************** loop_optimizer_finalize (void)
*** 142,147 ****
--- 143,150 ----
    if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
      release_recorded_exits ();
  
+   free_numbers_of_iterations_estimates ();
+ 
    /* If we should preserve loop structure, do not free it but clear
       flags that advanced properties are there as we are not preserving
       that in full.  */
Index: gcc/Makefile.in
===================================================================
*** gcc/Makefile.in	(revision 198334)
--- gcc/Makefile.in	(working copy)
*************** cfgloopmanip.o : cfgloopmanip.c $(CONFIG
*** 3181,3187 ****
  loop-init.o : loop-init.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(GGC_H) \
     $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) \
     coretypes.h $(TM_H) $(OBSTACK_H) $(TREE_PASS_H) $(FLAGS_H) \
!    $(REGS_H) $(DF_H)
  loop-unswitch.o : loop-unswitch.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(DUMPFILE_H) \
     $(RTL_H) $(TM_H) $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(PARAMS_H) \
--- 3189,3195 ----
  loop-init.o : loop-init.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(GGC_H) \
     $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) \
     coretypes.h $(TM_H) $(OBSTACK_H) $(TREE_PASS_H) $(FLAGS_H) \
!    $(REGS_H) $(DF_H) $(TREE_FLOW_H)
  loop-unswitch.o : loop-unswitch.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(DUMPFILE_H) \
     $(RTL_H) $(TM_H) $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(PARAMS_H) \
Index: gcc/testsuite/gcc.dg/torture/pr57081.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr57081.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr57081.c	(working copy)
***************
*** 0 ****
--- 1,22 ----
+ /* { dg-do compile } */
+ 
+ int a;
+ 
+ void f(void)
+ {
+   int b;
+ 
+   if(0)
+     lbl:
+ 	goto lbl;
+ 
+   if(b)
+     {
+       int p = 0;
+       goto lbl;
+     }
+ 
+   a = 0;
+   while(b++);
+   goto lbl;
+ }


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