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]

Re: [patch] for PR 26209


Hello,

> > > > 	PR tree-optimization/26209
> > > > 	* tree-ssa-loop.c (pass_scev_cprop): Add TODO_cleanup_cfg.
> > > > 	* tree-cfgcleanup.c (cleanup_control_flow): Remove dead
> > > > 	eh edges.
> > > > 	* tree-cfg.c (replace_uses_by): Do not alter cfg.
> > > > 
> > > OK.
> > 
> > FYI, I have bootstrapped/regtested this on
> > {i386,x86_64,ia64,s390,s390x,ppc,ppc64}-linux, no regressions.
> 
> Unfortunately, it creates a regression on i386-linux, though
> not in gcc testsuite:

this is already fixed in mainline.  The relevant part of the patch is

Index: tree-cfgcleanup.c
===================================================================
*** tree-cfgcleanup.c	(revision 109722)
--- tree-cfgcleanup.c	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 45,50 ****
--- 45,51 ----
  #include "cfglayout.h"
  #include "hashtab.h"
  #include "tree-ssa-propagate.h"
+ #include "tree-scalar-evolution.h"
  
  /* Remove any fallthru edge from EV.  Return true if an edge was removed.  */
  
*************** cleanup_tree_cfg (void)
*** 559,581 ****
  void
  cleanup_tree_cfg_loop (void)
  {
!   bitmap changed_bbs = BITMAP_ALLOC (NULL);
  
!   cleanup_tree_cfg ();
! 
!   fix_loop_structure (current_loops, changed_bbs);
!   calculate_dominance_info (CDI_DOMINATORS);
  
!   /* This usually does nothing.  But sometimes parts of cfg that originally
!      were inside a loop get out of it due to edge removal (since they
!      become unreachable by back edges from latch).  */
!   rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
  
!   BITMAP_FREE (changed_bbs);
  
  #ifdef ENABLE_CHECKING
!   verify_loop_structure (current_loops);
  #endif
  }
  
  /* Merge the PHI nodes at BB into those at BB's sole successor.  */
--- 560,585 ----
  void
  cleanup_tree_cfg_loop (void)
  {
!   bool changed = cleanup_tree_cfg ();
  
!   if (changed)
!     {
!       bitmap changed_bbs = BITMAP_ALLOC (NULL);
!       fix_loop_structure (current_loops, changed_bbs);
!       calculate_dominance_info (CDI_DOMINATORS);
  
!       /* This usually does nothing.  But sometimes parts of cfg that originally
! 	 were inside a loop get out of it due to edge removal (since they
! 	 become unreachable by back edges from latch).  */
!       rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
  
!       BITMAP_FREE (changed_bbs);
  
  #ifdef ENABLE_CHECKING
!       verify_loop_structure (current_loops);
  #endif
+       scev_reset ();
+     }
  }
  
  /* Merge the PHI nodes at BB into those at BB's sole successor.  */
Index: Makefile.in
===================================================================
*** Makefile.in	(revision 109722)
--- Makefile.in	(working copy)
*************** tree-cfgcleanup.o : tree-cfgcleanup.c $(
*** 1890,1896 ****
     $(DIAGNOSTIC_H) errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
     $(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \
     $(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h $(HASHTAB_H) toplev.h \
!    tree-ssa-propagate.h
  tree-tailcall.o : tree-tailcall.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) function.h $(TM_H) coretypes.h \
     $(TREE_DUMP_H) $(DIAGNOSTIC_H) except.h tree-pass.h $(FLAGS_H) langhooks.h \
--- 1890,1896 ----
     $(DIAGNOSTIC_H) errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
     $(TREE_DUMP_H) except.h langhooks.h $(CFGLOOP_H) tree-pass.h \
     $(CFGLAYOUT_H) $(BASIC_BLOCK_H) hard-reg-set.h $(HASHTAB_H) toplev.h \
!    tree-ssa-propagate.h $(SCEV_H)
  tree-tailcall.o : tree-tailcall.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) function.h $(TM_H) coretypes.h \
     $(TREE_DUMP_H) $(DIAGNOSTIC_H) except.h tree-pass.h $(FLAGS_H) langhooks.h \

> typedef struct
> {
>   unsigned short a;
>   unsigned short b;
> } T;
> T v[288];
> unsigned short w[16];
> 
> void bar (T *, int);
> 
> void
> foo (void)
> {
>   int n;
>   int bits;
> 
>   n = 0;
>   while (n <= 143)
>     v[n++].b = 8, w[8]++;
>   while (n <= 255)
>     v[n++].b = 9, w[9]++;
>   while (n <= 279)
>     v[n++].b = 7, w[7]++;
>   while (n <= 287)
>     v[n++].b = 8, w[8]++;
>   bar (v, 287);
> }
> 
> used to compile at -O2 without this patch just fine, now we ICE in
> #0  0x081b4971 in extract_array_ref (expr=0xf7c29000, base=0xffffd0d8, offset=0xffffd0d4) at ../../gcc/fold-const.c:5609
> #1  0x081b4811 in extract_array_ref (expr=0xf7c2e5a0, base=0xffffd1f8, offset=0xffffd1f4) at ../../gcc/fold-const.c:5571
> #2  0x081c0092 in fold_binary (code=GT_EXPR, type=0xf7baa4ac, op0=0xf7c2e5a0, op1=0xf7b9ad50) at ../../gcc/fold-const.c:8905
> #3  0x081c47cf in fold_build2_stat (code=GT_EXPR, type=0xf7baa4ac, op0=0xf7c2e5a0, op1=0xf7b9ad50) at ../../gcc/fold-const.c:10517
> #4  0x080e8483 in number_of_iterations_special (type=0xf7baa284, base0=0xf7c2e5a0, step0=0xf7b9aa38, code=LE_EXPR, base1=0xf7b9ad50, step1=0x0, niter=0xffffd718) at ../../gcc/tree-ssa-loop-niter.c:580
> #5  0x080e90d3 in number_of_iterations_exit (loop=0x8594c10, exit=0xf7ba8488, niter=0xffffd718, warn=0 '\0') at ../../gcc/tree-ssa-loop-niter.c:973
> #6  0x080f95bd in empty_loop_p (loop=0x8594c10) at ../../gcc/tree-ssa-loop-ivcanon.c:415
> #7  0x080f9dee in try_remove_empty_loop (loop=0x8594c10, changed=0xffffd793 "") at ../../gcc/tree-ssa-loop-ivcanon.c:555
> #8  0x080f9e42 in remove_empty_loops (loops=0x8573e08) at ../../gcc/tree-ssa-loop-ivcanon.c:572
> #9  0x080e7139 in tree_ssa_empty_loop () at ../../gcc/tree-ssa-loop.c:320
> 
> 5608      /* The next canonical form is a VAR_DECL with POINTER_TYPE.  */
> 5609      else if (SSA_VAR_P (expr)
> 5610               && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
> 5611        {
> 5612          *base = expr;
> 5613          *offset = NULL_TREE;
> (gdb) p debug_tree (expr)
>  <ssa_name 0xf7c29000 nothrow var <var_decl 0xf7ba61b8 n> def_stmt <ssa_name 0xf7c23d34>
>     version 50 in-free-list>
> (TREE_TYPE (expr) == NULL).
> 
> 	Jakub


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