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]

limited register renaming at -O2


Hi,
currently regrename is disabled at <-O3, as the debugging information is
useless then.  This is quite shame, as the most of registers are temporaries
that can be fluently renamed, because debug information is not depdendent
on them. Aditionally the situation of enabling rename-registers at -O3 only
is IMO somewhat confusing.

This patch changes register renamer to not rename user variables unless
new flag messy-debugging is set.  Then I can enable it at -O2 (and get
most of benefit done).

Tested on randomly inspecting the code that it appears to basically work
(ie if the output was incorrect, it was incorrect previously too).

Regtested/bootstrapped Athlon.

Honza

Fri Sep 28 19:01:28 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* flags.h (flag_messy_debugging): New flag.
	* regrename.c: (regrename_optimize): Avoid renaming of user
	variables unless messy_debugging is set.
	* toplev.c (flag_messy_debugging): New variable.
	(f_options): Add messy debugging.
	(toplev_main): Enable messy_debuging at O3.
	* invoke.texi (flag_messy_debugging): Document.
diff -Nrc3p /p2/cfg9/egcs/gcc/flags.h gcc/flags.h
*** /p2/cfg9/egcs/gcc/flags.h	Thu Sep 20 18:33:14 2001
--- gcc/flags.h	Thu Sep 27 12:54:54 2001
*************** extern int flag_trapv;
*** 575,580 ****
--- 575,584 ----
  
  extern int flag_prefix_function_name;
  
+ /* Nonzero if GCC is allowed to perform optimizations making debugging
+    particualry dificult.  */
+ extern int flag_messy_debugging;
+ 
  /* Value of the -G xx switch, and whether it was passed or not.  */
  extern int g_switch_value;
  extern int g_switch_set;
diff -Nrc3p /p2/cfg9/egcs/gcc/regrename.c gcc/regrename.c
*** /p2/cfg9/egcs/gcc/regrename.c	Thu Sep 20 18:33:13 2001
--- gcc/regrename.c	Thu Sep 27 14:26:42 2001
*************** regrename_optimize ()
*** 261,266 ****
--- 261,282 ----
  	      )
  	    continue;
  
+ 	  /* Disable register renaming for user variables,
+ 	     unless messy_debugging is set.  */
+ 	  if (!flag_messy_debugging
+ 	      && ORIGINAL_REGNO (*this->loc) >= FIRST_PSEUDO_REGISTER
+ 	      && REG_USERVAR_P (regno_reg_rtx [ORIGINAL_REGNO (*this->loc)]))
+ 	    {
+ 	      tick[reg] = this_tick++;
+ 	      if (rtl_dump_file)
+ 		{
+ 		  fprintf (rtl_dump_file,
+ 			   "Register %s in insn %d is user variable; not renamed\n",
+ 			   reg_names[reg], INSN_UID (this->insn));
+ 		}
+ 	      continue;
+ 	    }
+ 
  	  COPY_HARD_REG_SET (this_unavailable, unavailable);
  
  	  /* Find last entry on chain (which has the need_caller_save bit),
diff -Nrc3p /p2/cfg9/egcs/gcc/toplev.c gcc/toplev.c
*** /p2/cfg9/egcs/gcc/toplev.c	Thu Sep 20 18:33:13 2001
--- gcc/toplev.c	Thu Sep 27 15:36:53 2001
*************** int flag_merge_constants = 1;
*** 908,913 ****
--- 913,921 ----
     one, unconditionally renumber instruction UIDs.  */
  int flag_renumber_insns = 1;
  
+ /* If one, allow optimizations that makes debugging of resutling code dificult.  */
+ int flag_messy_debugging = 0;
+ 
  /* Values of the -falign-* flags: how much to align labels in code.
     0 means `use default', 1 means `don't align'.
     For each variable, there is an _log variant which is the power
*************** lang_independent_options f_options[] =
*** 1188,1193 ****
--- 1198,1205 ----
     N_("Report on permanent memory allocation at end of run") },
    { "trapv", &flag_trapv, 1,
     N_("Trap for signed overflow in addition / subtraction / multiplication.") },
+   { "messy-debugging", &flag_messy_debugging, 1,
+    N_("Allow optimizations making debug information very inacurate") },
  };
  
  /* Table of language-specific options.  */
*************** toplev_main (argc, argv)
*** 4759,4770 ****
        flag_strict_aliasing = 1;
        flag_delete_null_pointer_checks = 1;
        flag_reorder_blocks = 1;
      }
  
    if (optimize >= 3)
      {
        flag_inline_functions = 1;
!       flag_rename_registers = 1;
      }
  
    if (optimize < 2 || optimize_size)
--- 4790,4802 ----
        flag_strict_aliasing = 1;
        flag_delete_null_pointer_checks = 1;
        flag_reorder_blocks = 1;
+       flag_rename_registers = 1;
      }
  
    if (optimize >= 3)
      {
        flag_inline_functions = 1;
!       flag_messy_debugging = 1;
      }
  
    if (optimize < 2 || optimize_size)
Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/invoke.texi,v
retrieving revision 1.52
diff -c -3 -p -r1.52 invoke.texi
*** invoke.texi	2001/09/11 16:49:56	1.52
--- invoke.texi	2001/09/28 16:41:25
*************** in the following sections.
*** 274,280 ****
  -fschedule-insns  -fschedule-insns2 @gol
  -fsingle-precision-constant  -fssa -fssa-ccp -fssa-dce @gol
  -fstrength-reduce  -fstrict-aliasing  -fthread-jumps  -ftrapv @gol
! -funroll-all-loops  -funroll-loops  @gol
  --param @var{name}=@var{value}
  -O  -O0  -O1  -O2  -O3  -Os}
  
--- 274,280 ----
  -fschedule-insns  -fschedule-insns2 @gol
  -fsingle-precision-constant  -fssa -fssa-ccp -fssa-dce @gol
  -fstrength-reduce  -fstrict-aliasing  -fthread-jumps  -ftrapv @gol
! -funroll-all-loops  -funroll-loops -fmessy-debugging @gol
  --param @var{name}=@var{value}
  -O  -O0  -O1  -O2  -O3  -Os}
  
*************** of optimizations to be performed is desi
*** 3413,3418 ****
--- 3413,3430 ----
  
  Not all of the optimizations performed by GCC have @option{-f} options
  to control them.
+ 
+ @table @gcctabopt
+ @item -fmessy-debugging
+ @opindex fmessy-debugging
+ Some optimizations can be stronger if compiler give up ability to generate
+ at least approximately usefull debug information for optimized programs.
+ These transformation are not done when @option{-g} switch is not specified,
+ as politics is to get the code with @option{-g} and without equivalent,
+ except for debugging section.
+ 
+ This optimization enables such transformations.  It is still compatible with
+ @option{-g}, but debugging resulting programs will be even higher challenge.
  
  @table @gcctabopt
  @item -fstrength-reduce


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