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][RFC] Add -Otest for unit-testing optimization passes


This adds a crude unit-testing capability by enabling us to enable
optimization passes on top of -O0.  For this to work the following
patch adds an undocumented -Otest switch which sets optimize to 1
but does not enable any optimization passes (well - those without
a flag are still enabled - we'd need to change them to be enabled
from opts.c instead with appropriate flags).

I expect that we need to more carefully review pass properties
required/produced to make this fully usable, but with the following
start -Otest enables a lot less passes.

Do people think this is a useful start or is this something we want
to do in an entirely different way (and thus adding this isn't useful)?

A plain -Otest results in the following tree dumps:

960416-1.c.001t.tu                   960416-1.c.060t.addressables
960416-1.c.003t.original             960416-1.c.067t.retslot
960416-1.c.004t.gimple               960416-1.c.071t.mergephi2
960416-1.c.006t.vcg                  960416-1.c.074t.cselim
960416-1.c.009t.omplower             960416-1.c.075t.ifcombine
960416-1.c.010t.lower                960416-1.c.076t.phiopt1
960416-1.c.012t.eh                   960416-1.c.080t.cplxlower
960416-1.c.013t.cfg                  960416-1.c.089t.phiopt2
960416-1.c.014t.veclower             960416-1.c.090t.objsz
960416-1.c.015t.inline_param1        960416-1.c.093t.sincos
960416-1.c.022t.cleanup_cfg          960416-1.c.095t.crited
960416-1.c.024t.ssa                  960416-1.c.127t.recip
960416-1.c.025t.einline2             960416-1.c.137t.phiopt3
960416-1.c.026t.early_optimizations  960416-1.c.138t.fab
960416-1.c.033t.mergephi1            960416-1.c.147t.nrv
960416-1.c.042t.release_ssa          960416-1.c.149t.optimized
960416-1.c.043t.inline_param3        960416-1.c.229t.statistics

Comments?

I'm looking at this because I keep need to change dump file scanning
in testcases and/or add -fno-tree-XXX flags to optimizations to keep
gcc.dg/tree-ssa testresults sane.

It'll also be interesting to see Zdenek starting to do testsuite runs
with selectively enabled passes.

Thanks,
Richard.

2010-08-26  Richard Guenther  <rguenther@suse.de>

	* common.opt (Otest): New undocumented option.
	(decode_options): Handle Otest.
	(common_handle_option): Likewise.

Index: gcc/common.opt
===================================================================
*** gcc/common.opt.orig	2010-08-26 14:51:41.000000000 +0200
--- gcc/common.opt	2010-08-26 14:55:17.000000000 +0200
*************** Ofast
*** 84,89 ****
--- 84,93 ----
  Common Optimization
  Optimize for speed disregarding exact standards compliance
  
+ Otest
+ Common
+ Basic optimization level to enable optimization pass unit testing
+ 
  S
  Driver
  
*************** Common Report Var(flag_tree_dse) Optimiz
*** 1385,1391 ****
  Enable dead store elimination
  
  ftree-forwprop
! Common Report Var(flag_tree_forwprop) Init(1) Optimization
  Enable forward propagation on trees
  
  ftree-fre
--- 1389,1395 ----
  Enable dead store elimination
  
  ftree-forwprop
! Common Report Var(flag_tree_forwprop) Optimization
  Enable forward propagation on trees
  
  ftree-fre
*************** Common Report Var(flag_tree_loop_distrib
*** 1401,1407 ****
  Enable loop distribution for patterns transformed into a library call
  
  ftree-loop-im
! Common Report Var(flag_tree_loop_im) Init(1) Optimization
  Enable loop invariant motion on trees
  
  ftree-loop-linear
--- 1405,1411 ----
  Enable loop distribution for patterns transformed into a library call
  
  ftree-loop-im
! Common Report Var(flag_tree_loop_im) Optimization
  Enable loop invariant motion on trees
  
  ftree-loop-linear
*************** Common Report Var(flag_tree_loop_linear)
*** 1409,1419 ****
  Enable linear loop transforms on trees
  
  ftree-loop-ivcanon
! Common Report Var(flag_tree_loop_ivcanon) Init(1) Optimization
  Create canonical induction variables in loops
  
  ftree-loop-optimize
! Common Report Var(flag_tree_loop_optimize) Init(1) Optimization
  Enable loop optimizations on tree level
  
  ftree-parallelize-loops=
--- 1413,1423 ----
  Enable linear loop transforms on trees
  
  ftree-loop-ivcanon
! Common Report Var(flag_tree_loop_ivcanon) Optimization
  Create canonical induction variables in loops
  
  ftree-loop-optimize
! Common Report Var(flag_tree_loop_optimize) Optimization
  Enable loop optimizations on tree level
  
  ftree-parallelize-loops=
*************** Common Report Joined RejectNegative UInt
*** 1421,1427 ****
  Enable automatic parallelization of loops
  
  ftree-phiprop
! Common Report Var(flag_tree_phiprop) Init(1) Optimization
  Enable hoisting loads from conditional pointers.
  
  ftree-pre
--- 1425,1431 ----
  Enable automatic parallelization of loops
  
  ftree-phiprop
! Common Report Var(flag_tree_phiprop) Optimization
  Enable hoisting loads from conditional pointers.
  
  ftree-pre
*************** Common Report Var(flag_tree_pre) Optimiz
*** 1429,1439 ****
  Enable SSA-PRE optimization on trees
  
  ftree-pta
! Common Report Var(flag_tree_pta) Init(1) Optimization
  Perform function-local points-to analysis on trees.
  
  ftree-reassoc
! Common Report Var(flag_tree_reassoc) Init(1) Optimization
  Enable reassociation on tree level
  
  ftree-salias
--- 1433,1443 ----
  Enable SSA-PRE optimization on trees
  
  ftree-pta
! Common Report Var(flag_tree_pta) Optimization
  Perform function-local points-to analysis on trees.
  
  ftree-reassoc
! Common Report Var(flag_tree_reassoc) Optimization
  Enable reassociation on tree level
  
  ftree-salias
*************** Common RejectNegative Joined
*** 1544,1550 ****
  -ftree-vectorizer-verbose=<number>	Set the verbosity level of the vectorizer
  
  ftree-scev-cprop
! Common Report Var(flag_tree_scev_cprop) Init(1) Optimization
  Enable copy propagation of scalar-evolution information.
  
  ; -fverbose-asm causes extra commentary information to be produced in
--- 1548,1554 ----
  -ftree-vectorizer-verbose=<number>	Set the verbosity level of the vectorizer
  
  ftree-scev-cprop
! Common Report Var(flag_tree_scev_cprop) Optimization
  Enable copy propagation of scalar-evolution information.
  
  ; -fverbose-asm causes extra commentary information to be produced in
Index: gcc/opts.c
===================================================================
*** gcc/opts.c.orig	2010-08-26 14:51:41.000000000 +0200
--- gcc/opts.c	2010-08-26 14:55:15.000000000 +0200
*************** decode_options (unsigned int argc, const
*** 664,669 ****
--- 664,670 ----
    int opt3;
    int opt1_max;
    int ofast = 0;
+   int otest = 0;
  
    if (first_time_p)
      {
*************** decode_options (unsigned int argc, const
*** 747,752 ****
--- 748,761 ----
  	  ofast = 1;
  	  break;
  
+ 	case OPT_Otest:
+ 	  /* -Otest adds flags to -O0 but keeps optimze == 1.  */
+ 	  optimize_size = 0;
+ 	  optimize = 1;
+ 	  ofast = 1;
+ 	  otest = 1;
+ 	  break;
+ 
  	default:
  	  /* Ignore other options in this prescan.  */
  	  break;
*************** decode_options (unsigned int argc, const
*** 759,765 ****
      flag_ira_algorithm = IRA_ALGORITHM_PRIORITY;
  
    /* -O1 optimizations.  */
!   opt1 = (optimize >= 1);
    flag_defer_pop = opt1;
  #ifdef DELAY_SLOTS
    flag_delayed_branch = opt1;
--- 768,774 ----
      flag_ira_algorithm = IRA_ALGORITHM_PRIORITY;
  
    /* -O1 optimizations.  */
!   opt1 = (optimize >= 1) && !otest;
    flag_defer_pop = opt1;
  #ifdef DELAY_SLOTS
    flag_delayed_branch = opt1;
*************** decode_options (unsigned int argc, const
*** 789,794 ****
--- 798,811 ----
    flag_tree_copy_prop = opt1;
    flag_tree_sink = opt1;
    flag_tree_ch = opt1;
+   flag_tree_reassoc = opt1;
+   flag_tree_phiprop = opt1;
+   flag_tree_pta = opt1;
+   flag_tree_forwprop = opt1;
+   flag_tree_loop_optimize = opt1;
+   flag_tree_loop_im = opt1;
+   flag_tree_loop_ivcanon = opt1;
+   flag_tree_scev_cprop = opt1;
  
    /* -O2 optimizations.  */
    opt2 = (optimize >= 2);
*************** common_handle_option (const struct cl_de
*** 1589,1594 ****
--- 1606,1612 ----
      case OPT_O:
      case OPT_Os:
      case OPT_Ofast:
+     case OPT_Otest:
        /* Currently handled in a prescan.  */
        break;
  


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