This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Add -Otest for unit-testing optimization passes
On Thu, 26 Aug 2010, Joseph S. Myers wrote:
> On Thu, 26 Aug 2010, Richard Guenther wrote:
>
> > + case OPT_Otest:
> > + /* -Otest adds flags to -O0 but keeps optimze == 1. */
> > + optimize_size = 0;
> > + optimize = 1;
> > + ofast = 1;
> > + otest = 1;
> > + break;
>
> I think you should have the other OPT_O* cases set otest = 0, to preserve
> the principle that only the last -O* option matters (note that
> gcc.c:check_live_switch contains such an assumption), and add OPT_Otest to
> the OPT_O* cases in java/jvspec.c. That is, keep it as if there is a
> single -O option that takes enumerated arguments { 0, 1, 2, 3, s, fast,
> test } (plus -O meaning -O1 and -On for n > 3 meaning -O3).
Wow, java/jvspec.c - never noticed that ;)
Here is an updated patch, I'll probably test/commit the optimization
enablement changes separately.
Richard.
2010-08-27 Richard Guenther <rguenther@suse.de>
* common.opt (Otest): New undocumented option.
(decode_options): Handle Otest.
(common_handle_option): Likewise.
java/
* jvspec.c (lang_specific_driver): Handle Otest.
Index: gcc/common.opt
===================================================================
*** gcc/common.opt.orig 2010-08-26 16:19:28.000000000 +0200
--- gcc/common.opt 2010-08-27 12:46:09.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 16:19:28.000000000 +0200
--- gcc/opts.c 2010-08-27 12:46:49.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
*** 714,719 ****
--- 715,721 ----
optimize = 1;
optimize_size = 0;
ofast = 0;
+ otest = 0;
}
else
{
*************** decode_options (unsigned int argc, const
*** 728,733 ****
--- 730,736 ----
optimize = 255;
optimize_size = 0;
ofast = 0;
+ otest = 0;
}
}
break;
*************** decode_options (unsigned int argc, const
*** 738,743 ****
--- 741,747 ----
/* Optimizing for size forces optimize to be 2. */
optimize = 2;
ofast = 0;
+ otest = 0;
break;
case OPT_Ofast:
*************** decode_options (unsigned int argc, const
*** 745,750 ****
--- 749,763 ----
optimize_size = 0;
optimize = 3;
ofast = 1;
+ otest = 0;
+ break;
+
+ case OPT_Otest:
+ /* -Otest adds flags to -O0 but keeps optimze == 1. */
+ optimize_size = 0;
+ optimize = 1;
+ ofast = 0;
+ otest = 1;
break;
default:
*************** 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;
--- 772,778 ----
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 ****
--- 802,815 ----
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 ****
--- 1610,1616 ----
case OPT_O:
case OPT_Os:
case OPT_Ofast:
+ case OPT_Otest:
/* Currently handled in a prescan. */
break;
Index: gcc/java/jvspec.c
===================================================================
*** gcc/java/jvspec.c.orig 2010-08-24 10:32:23.000000000 +0200
--- gcc/java/jvspec.c 2010-08-27 12:47:28.000000000 +0200
*************** lang_specific_driver (struct cl_decoded_
*** 292,297 ****
--- 292,298 ----
case OPT_O:
case OPT_Os:
case OPT_Ofast:
+ case OPT_Otest:
saw_O = 1;
break;