There is code that sets various --param values defaults depending on optimizations. (look for uses of maybe_set_param_value). This is done only at startup and is not adjusted when command line options change. For example gcc -Ofast -flto t.c -c gcc t.o -Og will get -Og --param values while compiling functions from t.o which are intended to be optimized with -Ofast
I'll pick some.
Created attachment 47014 [details] prototype Something like this. Note the behavior changes if the user manually specifies any of the parameters. We'd need to add a maybe_get_and_adjust_param_value that gets the unaltered value if the user specified it. But for that we'd have to hard pass-in global_options and global_options_set (or hardcode it in params.c). But then the behavior between -O2 and -O2 --param max-stores-to-sink=2 would be different (even though that's the documented default of the --param) - which is btw the current behavior. We could check against the default value but that means the behavior is different if targets change the param and the behavior differs between --param X=default and X=default-1 (drastically in the case of dropping to zero). I think for the vectorizer the only problematic case is PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS, the others are documented to be turned off. Likewise max-stores-to-sink. So I made vect-maxversion-for-alias-checks adjusted relatively with -fvect-cost-model=cheap so a global changed --param still has an effect.
Some tackled, will try to tackle those depending on -On as well.
Author: rguenth Date: Thu Oct 10 14:02:25 2019 New Revision: 276807 URL: https://gcc.gnu.org/viewcvs?rev=276807&root=gcc&view=rev Log: 2019-10-10 Richard Biener <rguenther@suse.de> PR middle-end/92046 * opts.c (finish_options): Do not influence global --params from options that are adjustable per function. * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Apply --param adjustment based on active cost-model. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Disable further store-sinking when vectorization or if-conversion are not enabled. Modified: trunk/gcc/ChangeLog trunk/gcc/opts.c trunk/gcc/tree-ssa-phiopt.c trunk/gcc/tree-vect-data-refs.c
Author: rguenth Date: Fri Oct 11 10:45:48 2019 New Revision: 276876 URL: https://gcc.gnu.org/viewcvs?rev=276876&root=gcc&view=rev Log: 2019-10-11 Richard Biener <rguenther@suse.de> PR tree-optimization/92066 PR tree-optimization/92046 * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Fix bogus cost model check. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-vect-data-refs.c
Author: rguenth Date: Mon Oct 14 14:03:35 2019 New Revision: 276963 URL: https://gcc.gnu.org/viewcvs?rev=276963&root=gcc&view=rev Log: 2019-10-14 Richard Biener <rguenther@suse.de> PR middle-end/92046 * dse.c (scan_insn): Use param max_active_local_stores. (dse_step1): Get PARAM_MAX_DSE_ACTIVE_LOCAL_STORES and adjust based on optimization level. * loop-invariant.c (move_loop_invariants): Adjust LOOP_INVARIANT_MAX_BBS_IN_LOOP based on optimization level. * opts.c (default_options_optimization): Do not adjust PARAM_MAX_DSE_ACTIVE_LOCAL_STORES and LOOP_INVARIANT_MAX_BBS_IN_LOOP here. Modified: trunk/gcc/ChangeLog trunk/gcc/dse.c trunk/gcc/loop-invariant.c trunk/gcc/opts.c
Author: rguenth Date: Tue Oct 15 07:28:26 2019 New Revision: 276985 URL: https://gcc.gnu.org/viewcvs?rev=276985&root=gcc&view=rev Log: 2019-10-15 Richard Biener <rguenther@suse.de> PR middle-end/92046 * common.opt (fallow-store-data-races): New. * params.def (PARAM_ALLOW_STORE_DATA_RACES): Remove. * params.h (ALLOW_STORE_DATA_RACES): Likewise. * doc/invoke.texi (fallow-store-data-races): Document. (--param allow-store-data-races): Remove docs. * opts.c (default_options_table): Enable -fallow-store-data-races at -Ofast. (default_options_optimization): Do not enable --param allow-store-data-races at -Ofast. * tree-if-conv.c (ifcvt_memrefs_wont_trap): Use flag_store_data_races instead of PARAM_ALLOW_STORE_DATA_RACES. * tree-ssa-loop-im.c (execute_sm): Likewise. * c-c++-common/cxxbitfields-3.c: Adjust. * c-c++-common/cxxbitfields-6.c: Likewise. * c-c++-common/simulate-thread/bitfields-1.c: Likewise. * c-c++-common/simulate-thread/bitfields-2.c: Likewise. * c-c++-common/simulate-thread/bitfields-3.c: Likewise. * c-c++-common/simulate-thread/bitfields-4.c: Likewise. * g++.dg/simulate-thread/bitfields-2.C: Likewise. * g++.dg/simulate-thread/bitfields.C: Likewise. * gcc.dg/lto/pr52097_0.c: Likewise. * gcc.dg/simulate-thread/speculative-store-2.c: Likewise. * gcc.dg/simulate-thread/speculative-store-3.c: Likewise. * gcc.dg/simulate-thread/speculative-store-4.c: Likewise. * gcc.dg/simulate-thread/speculative-store.c: Likewise. * gcc.dg/tree-ssa/20050314-1.c: Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/common.opt trunk/gcc/doc/invoke.texi trunk/gcc/opts.c trunk/gcc/params.def trunk/gcc/params.h trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/cxxbitfields-3.c trunk/gcc/testsuite/c-c++-common/cxxbitfields-6.c trunk/gcc/testsuite/c-c++-common/simulate-thread/bitfields-1.c trunk/gcc/testsuite/c-c++-common/simulate-thread/bitfields-2.c trunk/gcc/testsuite/c-c++-common/simulate-thread/bitfields-3.c trunk/gcc/testsuite/c-c++-common/simulate-thread/bitfields-4.c trunk/gcc/testsuite/g++.dg/simulate-thread/bitfields-2.C trunk/gcc/testsuite/g++.dg/simulate-thread/bitfields.C trunk/gcc/testsuite/gcc.dg/lto/pr52097_0.c trunk/gcc/testsuite/gcc.dg/simulate-thread/speculative-store-2.c trunk/gcc/testsuite/gcc.dg/simulate-thread/speculative-store-3.c trunk/gcc/testsuite/gcc.dg/simulate-thread/speculative-store-4.c trunk/gcc/testsuite/gcc.dg/simulate-thread/speculative-store.c trunk/gcc/testsuite/gcc.dg/tree-ssa/20050314-1.c trunk/gcc/tree-if-conv.c trunk/gcc/tree-ssa-loop-im.c
@Richi: Can you please mention the new option -fallow-store-data-races at https://gcc.gnu.org/gcc-10/changes.html?
I'm recommending to close it, let's continue in PR92860.