aboutsummaryrefslogtreecommitdiff
path: root/gcc/params.opt
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2022-12-14 00:33:06 +0100
committerMartin Jambor <mjambor@suse.cz>2022-12-14 00:58:10 +0100
commit10478270fe0c39c59eb0f35d19356a63bdf3a2ad (patch)
tree10fd7181654aecbb9ea1a3b00ee566f3986ec364 /gcc/params.opt
parent095a13eda2caf6842096a3ab78b2081c50fe8799 (diff)
downloadgcc-10478270fe0c39c59eb0f35d19356a63bdf3a2ad.zip
gcc-10478270fe0c39c59eb0f35d19356a63bdf3a2ad.tar.gz
gcc-10478270fe0c39c59eb0f35d19356a63bdf3a2ad.tar.bz2
ipa-sra: Treat REFERENCE_TYPES as always dereferencable
C++ and especially Fortran pass data by references which are not pointers potentially pointing anywhere and so can be assumed to be safely dereferencable. This patch teaches IPA-SRA to treat them as such and avoid the dance we do to prove that we can move loads from them to the caller. When we do not know that a dereference will happen all the time, we need a heuristics so that we do not force memory accesses that normally happen only rarely. The patch simply uses the (possibly guessed) profile and checks whether the (expected) number of loads is at least half of function invocations invocations - the half is now configurable with a param as requested by Honza. gcc/ChangeLog: 2022-12-13 Martin Jambor <mjambor@suse.cz> PR ipa/103585 * params.opt (ipa-sra-deref-prob-threshold): New parameter. * doc/invoke.texi (ipa-sra-deref-prob-threshold): Document it. * ipa-sra.cc (struct gensum_param_access): New field load_count. (struct gensum_param_desc): New field safe_ref, adjusted comments. (by_ref_count): Renamed to unsafe_by_ref_count, adjusted all uses. (dump_gensum_access): Dump the new field. (dump_gensum_param_descriptor): Likewise. (create_parameter_descriptors): Set safe_ref field, move setting by_ref forward. Only increment unsafe_by_ref_count for unsafe by_ref parameters. (allocate_access): Initialize new field. (mark_param_dereference): Adjust indentation. Only add data to bb_dereferences for unsafe by_ref parameters. (scan_expr_access): For loads, accumulate BB counts. (dereference_probable_p): New function. (check_gensum_access): Fix leading comment, add parameter FUN. Check cumulative counts of loads for safe by_ref accesses instead of dereferences. (process_scan_results): Do not propagate dereference distances for safe by_ref parameters. Pass fun to check_gensum_access. Safe by_ref params do not need the postdominance check. gcc/testsuite/ChangeLog: 2022-11-11 Martin Jambor <mjambor@suse.cz> * g++.dg/ipa/ipa-sra-5.C: New test
Diffstat (limited to 'gcc/params.opt')
-rw-r--r--gcc/params.opt4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/params.opt b/gcc/params.opt
index 397ec0b..a574f17 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -282,6 +282,10 @@ Maximum number of different predicates used to track properties of loops in IPA
Common Joined UInteger Var(param_ipa_max_switch_predicate_bounds) Init(5) Param Optimization
Maximal number of boundary endpoints of case ranges of switch statement used during IPA function summary generation.
+-param=ipa-sra-deref-prob-threshold=
+Common Joined UInteger Var(param_ipa_sra_deref_prob_threshold) Init(50) IntegerRange(0, 100) Param Optimization
+Minimum probability (in percent) of dereferencing of a function pointer parameter for it to be considered for replacement with simple values.
+
-param=ipa-sra-max-replacements=
Common Joined UInteger Var(param_ipa_sra_max_replacements) Optimization Init(8) IntegerRange(0, 16) Param
Maximum pieces that IPA-SRA tracks per formal parameter, as a consequence, also the maximum number of replacements of a formal parameter.