Bug 92046 - Command line options (that are per-functions) are affecting --params which are global.
Summary: Command line options (that are per-functions) are affecting --params which ar...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-10 11:51 UTC by Jan Hubicka
Modified: 2020-03-25 15:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-10-10 00:00:00


Attachments
prototype (1.40 KB, patch)
2019-10-10 12:18 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2019-10-10 11:51:32 UTC
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
Comment 1 Richard Biener 2019-10-10 11:52:42 UTC
I'll pick some.
Comment 2 Richard Biener 2019-10-10 12:18:46 UTC
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.
Comment 3 Richard Biener 2019-10-10 14:01:49 UTC
Some tackled, will try to tackle those depending on -On as well.
Comment 4 Richard Biener 2019-10-10 14:02:56 UTC
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
Comment 5 Richard Biener 2019-10-11 10:46:26 UTC
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
Comment 6 Richard Biener 2019-10-14 14:04:06 UTC
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
Comment 7 Richard Biener 2019-10-15 07:28:58 UTC
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
Comment 8 Martin Liška 2020-03-25 14:58:28 UTC
@Richi: Can you please mention the new option -fallow-store-data-races at https://gcc.gnu.org/gcc-10/changes.html?
Comment 9 Martin Liška 2020-03-25 15:02:26 UTC
I'm recommending to close it, let's continue in PR92860.