gcse dump files (Was: Re: gcse related bugfix Re: [bugs] Another ICE)

Jan Hubicka jh@suse.cz
Mon May 14 07:08:00 GMT 2001


>     Also the gcse dumps are wonderfully useless and completely
>     missdirected me while hunting the problem. Can't we create separate
>     dump for the gcse itself, the motion passes and the cse, jump run
>     afterwards?
> 
> I agree this is a good idea.
Like this patch?

Mon May 14 15:58:48 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* gcse.c (store_motion): Make global; add "file" parameter;
	don't dump the rtl stream.
	* rtl.h (store_mtion): Declare.
	* toplev.c (dump_file_index): Add DFI_smotion and DFI_gcse_cleanup
	(rest_of_compilation): Properly open and close the DFI_smotion
	and DFI_gcse_cleanup files; call store_motion pass separately;
	call it even when gcse is disabled as it is independent.
Index: gcse.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/gcse.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 gcse.c
*** gcse.c	2001/05/14 11:32:57	1.11
--- gcse.c	2001/05/14 12:57:40
*************** static void replace_store_insn		PARAMS (
*** 706,712 ****
  static void delete_store		PARAMS ((struct ls_expr *, 
  						 basic_block));
  static void free_store_memory		PARAMS ((void));
- static void store_motion		PARAMS ((void));
  
  /* Entry point for global common subexpression elimination.
     F is the first instruction in the function.  */
--- 706,711 ----
*************** gcse_main (f, file)
*** 920,927 ****
    end_alias_analysis ();
    allocate_reg_info (max_reg_num (), FALSE, FALSE);
  
-   if (!optimize_size && flag_gcse_sm)
-     store_motion ();
    /* Record where pseudo-registers are set.  */
    return run_jump_opt_after_gcse;
  }
--- 919,924 ----
*************** free_store_memory ()
*** 7086,7104 ****
  /* Perform store motion. Much like gcse, except we move expressions the
     other way by looking at the flowgraph in reverse.  */
  
! static void
! store_motion ()
  {
    int x;
    struct ls_expr * ptr;
    int update_flow = 0;
- 
-   if (gcse_file)
-     {
-       fprintf (gcse_file, "before store motion\n");
-       print_rtl (gcse_file, get_insns ());
-     }
  
  
    init_alias_analysis ();
  
--- 7083,7099 ----
  /* Perform store motion. Much like gcse, except we move expressions the
     other way by looking at the flowgraph in reverse.  */
  
! void
! store_motion (file)
!      FILE *file;
  {
    int x;
    struct ls_expr * ptr;
    int update_flow = 0;
  
+   /* For calling dump_foo fns from gdb.  */
+   debug_stderr = stderr;
+   gcse_file = file;
  
    init_alias_analysis ();
  
Index: recog.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/recog.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 recog.c
*** recog.c	2001/05/03 15:57:43	1.8
--- recog.c	2001/05/14 12:57:41
*************** apply_change_group ()
*** 331,336 ****
--- 331,345 ----
        if (object == 0)
  	continue;
  
+       /* In case previous change went to the same object, just skip it.  */
+ #if 0
+       if (i && changes[i-1].object == object)
+       {
+ 	fprintf (stderr, "my god\n");
+ 	continue;
+       }
+ #endif
+ 
        if (GET_CODE (object) == MEM)
  	{
  	  if (! memory_address_p (GET_MODE (object), XEXP (object, 0)))
*************** apply_change_group ()
*** 392,397 ****
--- 401,417 ----
    else
      {
        cancel_changes (0);
+ #if 0
+       for (i = 0; i < num_changes; i++)
+ 	{
+ 	  rtx object = changes[i].object;
+ 
+ 	  if (object == 0)
+ 	    continue;
+ 	  if (insn_invalid_p (object))
+ 	    abort ();
+ 	}
+ #endif
        return 0;
      }
  }
Index: rtl.h
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/rtl.h,v
retrieving revision 1.10
diff -c -3 -p -r1.10 rtl.h
*** rtl.h	2001/05/03 15:57:44	1.10
--- rtl.h	2001/05/14 12:57:41
*************** extern rtx expand_mult_highpart		PARAMS 
*** 1830,1835 ****
--- 1830,1836 ----
  /* In gcse.c */
  #ifdef BUFSIZ
  extern int gcse_main			PARAMS ((rtx, FILE *));
+ extern void store_motion		PARAMS ((FILE *));
  #endif
  
  /* In global.c */
Index: toplev.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/toplev.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 toplev.c
*** toplev.c	2001/05/03 15:57:44	1.14
--- toplev.c	2001/05/14 12:57:42
*************** enum dump_file_index
*** 257,262 ****
--- 257,264 ----
    DFI_dce,
    DFI_ussa,
    DFI_gcse,
+   DFI_smotion,
+   DFI_gcse_cleanup,
    DFI_loop,
    DFI_cse2,
    DFI_cfg,
*************** enum dump_file_index
*** 287,293 ****
  
     Remaining -d letters:
  
! 	"              o q   u     "
  	"       H  K   OPQ  TUVW YZ"
  */
  
--- 289,295 ----
  
     Remaining -d letters:
  
! 	"                q   u     "
  	"       H  K   OPQ  TUVW YZ"
  */
  
*************** struct dump_file_info dump_file[DFI_MAX]
*** 303,308 ****
--- 305,312 ----
    { "dce",	'X', 1, 0, 0 },
    { "ussa",	'e', 1, 0, 0 },	/* Yes, duplicate enable switch.  */
    { "gcse",	'G', 1, 0, 0 },
+   { "smotion",	'o', 1, 0, 0 },
+   { "gcse_cleanup",'G', 1, 0, 0 }, /* Yes, duplicate enable switch.  */
    { "loop",	'L', 1, 0, 0 },
    { "cse2",	't', 1, 0, 0 },
    { "cfg",	'f', 1, 0, 0 },
*************** rest_of_compilation (decl)
*** 3082,3103 ****
  
    /* Perform global cse.  */
  
!   if (optimize > 0 && flag_gcse)
      {
        int save_csb, save_cfj;
        int tem2 = 0;
  
        timevar_push (TV_GCSE);
-       open_dump_file (DFI_gcse, decl);
  
        find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
        cleanup_cfg ();
!       tem = gcse_main (insns, rtl_dump_file);
  
        save_csb = flag_cse_skip_blocks;
        save_cfj = flag_cse_follow_jumps;
        flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
  
        /* If -fexpensive-optimizations, re-run CSE to clean up things done
  	 by gcse.  */
        if (flag_expensive_optimizations)
--- 3086,3118 ----
  
    /* Perform global cse.  */
  
!   if (optimize > 0 && (flag_gcse || flag_gcse_sm))
      {
        int save_csb, save_cfj;
        int tem2 = 0;
  
        timevar_push (TV_GCSE);
  
        find_basic_blocks (insns, max_reg_num (), rtl_dump_file);
        cleanup_cfg ();
!       if (flag_gcse)
! 	{
! 	  open_dump_file (DFI_gcse, decl);
! 	  tem = gcse_main (insns, rtl_dump_file);
! 	  close_dump_file (DFI_gcse, print_rtl, insns);
! 	}
! 
  
+       open_dump_file (DFI_smotion, decl);
+       if (!optimize_size)
+ 	store_motion (rtl_dump_file);
+       close_dump_file (DFI_smotion, print_rtl, insns);
+ 
        save_csb = flag_cse_skip_blocks;
        save_cfj = flag_cse_follow_jumps;
        flag_cse_skip_blocks = flag_cse_follow_jumps = 0;
  
+       open_dump_file (DFI_gcse_cleanup, decl);
        /* If -fexpensive-optimizations, re-run CSE to clean up things done
  	 by gcse.  */
        if (flag_expensive_optimizations)
*************** rest_of_compilation (decl)
*** 3127,3134 ****
  	      timevar_pop (TV_CSE);
  	    }
  	}
! 
!       close_dump_file (DFI_gcse, print_rtl, insns);
        timevar_pop (TV_GCSE);
  
        ggc_collect ();
--- 3142,3148 ----
  	      timevar_pop (TV_CSE);
  	    }
  	}
!       close_dump_file (DFI_gcse_cleanup, print_rtl, insns);
        timevar_pop (TV_GCSE);
  
        ggc_collect ();



More information about the Gcc-patches mailing list