This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Expose MAX_PASSES in gcse.c to command line
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: Expose MAX_PASSES in gcse.c to command line
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Thu, 30 Nov 2000 16:27:23 -0500 (EST)
- Cc: lucier at math dot purdue dot edu, feeley at iro dot umontreal dot ca
The following patch changes the macro MAX_PASSES in gcse.c to a
variable that can be controlled by a -fgcse-limit= command-line
switch.
I wanted this to make it easier to experiment with the number of
passes. For example, with the file I'm using to test the correctness
of gcse right now, I get with
../../gcc/objdir/gcc/cc1 -O2 -fno-math-errno -mcpu=ev6 -mieee -fgcse-limit=3 -da -gstabs _io.i
the following
% grep pass *08*
GCSE pass 1
CPROP of ___H__20___io, pass 1: 1637953 bytes needed, 1 const props, 10 copy props
PRE GCSE of ___H__20___io, pass 1: 2914017 bytes needed, 110 substs, 3156 insns created
GCSE pass 2
CPROP of ___H__20___io, pass 2: 1777907 bytes needed, 3 const props, 116 copy props
PRE GCSE of ___H__20___io, pass 2: 3082083 bytes needed, 1689 substs, 94 insns created
GCSE pass 3
CPROP of ___H__20___io, pass 3: 1821076 bytes needed, 3 const props, 492 copy props
PRE GCSE of ___H__20___io, pass 3: 3047436 bytes needed, 2 substs, 1 insns created
CPROP of ___H__20___io, pass 4: 4900524 bytes needed, 2 const props, 0 copy props
GCSE of ___H__20___io: 7016 basic blocks, 3 passes, 3632443 bytes
so there are many more copy props in later passes than in the first.
This bootstraps on alphaev6-unknown-linux-gnu with BOOT_CFLAGS='-O2 -g -fgcse-limit=3' and no regressions with
make -k check RUNTESTFLAGS="--tool_opts '-fgcse-limit=3'" > & check.log
Brad Lucier
* gcse.c (gcse_max_passes): Introduce new global. Use it.
* flags.h (gcse_max_passes): Declare it.
* toplev.c (-fgcse-limit=): Introduce new flag.
* invoke.texi (-fgcse-limit=): Document it.
===================================================================
RCS file: RCS/flags.h,v
retrieving revision 1.1
diff -cp -r1.1 flags.h
*** flags.h 2000/11/30 19:39:25 1.1
--- flags.h 2000/11/30 19:40:31
*************** extern int g_switch_set;
*** 572,577 ****
--- 572,581 ----
extern int inline_max_insns;
+ /* Value of the -fgcse-limit flag. */
+
+ extern int gcse_max_passes;
+
/* 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
===================================================================
RCS file: RCS/gcse.c,v
retrieving revision 1.1
diff -cp -r1.1 gcse.c
*** gcse.c 2000/11/30 19:40:36 1.1
--- gcse.c 2000/11/30 19:42:55
*************** Boston, MA 02111-1307, USA. */
*** 165,171 ****
#define obstack_chunk_free free
/* Maximum number of passes to perform. */
! #define MAX_PASSES 1
/* Propagate flow information through back edges and thus enable PRE's
moving loop invariant calculations out of loops.
--- 165,172 ----
#define obstack_chunk_free free
/* Maximum number of passes to perform. */
!
! int gcse_max_passes = 1;
/* Propagate flow information through back edges and thus enable PRE's
moving loop invariant calculations out of loops.
*************** Boston, MA 02111-1307, USA. */
*** 230,237 ****
substitutions.
PRE is quite expensive in complicated functions because the DFA can take
! awhile to converge. Hence we only perform one pass. Macro MAX_PASSES can
! be modified if one wants to experiment.
**********************
--- 231,238 ----
substitutions.
PRE is quite expensive in complicated functions because the DFA can take
! awhile to converge. Hence we only perform one pass. Flag -fgcse-limit can
! be set if one wants to experiment.
**********************
*************** gcse_main (f, file)
*** 719,725 ****
max_pass_bytes = 0;
gcse_obstack_bottom = gcse_alloc (1);
changed = 1;
! while (changed && pass < MAX_PASSES)
{
changed = 0;
if (file)
--- 720,726 ----
max_pass_bytes = 0;
gcse_obstack_bottom = gcse_alloc (1);
changed = 1;
! while (changed && pass < gcse_max_passes)
{
changed = 0;
if (file)
===================================================================
RCS file: RCS/invoke.texi,v
retrieving revision 1.1
diff -cp -r1.1 invoke.texi
*** invoke.texi 2000/11/30 19:46:44 1.1
--- invoke.texi 2000/11/30 19:49:51
*************** in the following sections.
*** 190,196 ****
-fexpensive-optimizations -ffast-math -ffloat-store
-fforce-addr -fforce-mem -ffunction-sections -fgcse
-finline-functions -finline-limit=@var{n} -fkeep-inline-functions
! -fkeep-static-consts -fmove-all-movables
-fno-default-inline -fno-defer-pop
-fno-function-cse -fno-inline -fno-math-errno -fno-peephole
-fomit-frame-pointer -foptimize-register-move
--- 190,196 ----
-fexpensive-optimizations -ffast-math -ffloat-store
-fforce-addr -fforce-mem -ffunction-sections -fgcse
-finline-functions -finline-limit=@var{n} -fkeep-inline-functions
! -fgcse-limit=@var{n} -fkeep-static-consts -fmove-all-movables
-fno-default-inline -fno-defer-pop
-fno-function-cse -fno-inline -fno-math-errno -fno-peephole
-fomit-frame-pointer -foptimize-register-move
*************** Even if all calls to a given function ar
*** 2768,2773 ****
--- 2768,2778 ----
is declared @code{static}, nevertheless output a separate run-time
callable version of the function. This switch does not affect
@code{extern inline} functions.
+
+ @item -fgcse-limit=@var{n}
+ By default, GCC runs the gcse pass once. Setting this parameter
+ to a higher value will allow more iterations of the gcse pass,
+ possibly leading to better optimization.
@item -fkeep-static-consts
Emit variables declared @code{static const} when optimization isn't turned
===================================================================
RCS file: RCS/toplev.c,v
retrieving revision 1.1
diff -cp -r1.1 toplev.c
*** toplev.c 2000/11/30 19:38:18 1.1
--- toplev.c 2000/11/30 19:44:30
*************** decode_f_option (arg)
*** 4054,4059 ****
--- 4054,4062 ----
else if ((option_value = skip_leading_substring (arg, "sched-verbose=")))
fix_sched_param ("verbose", option_value);
#endif
+ else if ((option_value = skip_leading_substring (arg, "gcse-limit=")))
+ gcse_max_passes
+ = read_integral_parameter (option_value, arg - 2, gcse_max_passes);
else if ((option_value = skip_leading_substring (arg, "fixed-")))
fix_register (option_value, 1, 1);
else if ((option_value = skip_leading_substring (arg, "call-used-")))