Commit 9b14fc33 by Feng Xue Committed by Feng Xue

Enable recursive function versioning

2019-12-02  Feng Xue <fxue@os.amperecomputing.com>

        PR ipa/92133
        * doc/invoke.texi (ipa-cp-max-recursive-depth): Document new option.
        (ipa-cp-min-recursive-probability): Likewise.
        * params.opt (ipa-cp-max-recursive-depth): New.
        (ipa-cp-min-recursive-probability): Likewise.
        * ipa-cp.c (ipcp_lattice<valtype>::add_value): Add two new parameters
        val_p and unlimited.
        (self_recursively_generated_p): New function.
        (get_val_across_arith_op): Likewise.
        (propagate_vals_across_arith_jfunc): Add constant propagation for
        self-recursive function.
        (incorporate_penalties): Do not penalize pure self-recursive function.
        (good_cloning_opportunity_p): Dump node_is_self_scc flag.
        (propagate_constants_topo): Set node_is_self_scc flag for cgraph node.
        (get_info_about_necessary_edges): Relax hotness check for edge to
        self-recursive function.
        * ipa-prop.h (ipa_node_params): Add new field node_is_self_scc.

2019-12-02  Feng Xue  <fxue@os.amperecomputing.com>

        PR ipa/92133
        * gcc.dg/ipa/ipa-clone-2.c: New test.

From-SVN: r278893
parent 4569f8b3
2019-12-02 Feng Xue <fxue@os.amperecomputing.com>
PR ipa/92133
* doc/invoke.texi (ipa-cp-max-recursive-depth): Document new option.
(ipa-cp-min-recursive-probability): Likewise.
* params.opt (ipa-cp-max-recursive-depth): New.
(ipa-cp-min-recursive-probability): Likewise.
* ipa-cp.c (ipcp_lattice<valtype>::add_value): Add two new parameters
val_p and unlimited.
(self_recursively_generated_p): New function.
(get_val_across_arith_op): Likewise.
(propagate_vals_across_arith_jfunc): Add constant propagation for
self-recursive function.
(incorporate_penalties): Do not penalize pure self-recursive function.
(good_cloning_opportunity_p): Dump node_is_self_scc flag.
(propagate_constants_topo): Set node_is_self_scc flag for cgraph node.
(get_info_about_necessary_edges): Relax hotness check for edge to
self-recursive function.
* ipa-prop.h (ipa_node_params): Add new field node_is_self_scc.
2019-12-01 Sandra Loosemore <sandra@codesourcery.com>
PR target/92499
......@@ -12035,6 +12035,13 @@ IPA-CP calculates its own score of cloning profitability heuristics
and performs those cloning opportunities with scores that exceed
@option{ipa-cp-eval-threshold}.
@item ipa-cp-max-recursive-depth
Maximum depth of recursive cloning for self-recursive function.
@item ipa-cp-min-recursive-probability
Recursive cloning only when the probability of call being executed exceeds
the parameter.
@item ipa-cp-recursion-penalty
Percentage penalty the recursive functions will receive when they
are evaluated for cloning.
......@@ -497,6 +497,8 @@ public:
unsigned node_dead : 1;
/* Node is involved in a recursion, potentionally indirect. */
unsigned node_within_scc : 1;
/* Node contains only direct recursion. */
unsigned node_is_self_scc : 1;
/* Node is calling a private function called only once. */
unsigned node_calling_single_call : 1;
/* False when there is something makes versioning impossible. */
......
......@@ -198,6 +198,14 @@ Threshold ipa-cp opportunity evaluation that is still considered beneficial to c
Common Joined UInteger Var(param_ipa_cp_loop_hint_bonus) Init(64) Param
Compile-time bonus IPA-CP assigns to candidates which make loop bounds or strides known.
-param=ipa-cp-max-recursive-depth=
Common Joined UInteger Var(param_ipa_cp_max_recursive_depth) Init(8) Param
Maximum depth of recursive cloning for self-recursive function.
-param=ipa-cp-min-recursive-probability=
Common Joined UInteger Var(param_ipa_cp_min_recursive_probability) Init(2) Param
Recursive cloning only when the probability of call being executed exceeds the parameter.
-param=ipa-cp-recursion-penalty=
Common Joined UInteger Var(param_ipa_cp_recursion_penalty) Init(40) IntegerRange(0, 100) Param
Percentage penalty the recursive functions will receive when they are evaluated for cloning.
......
2019-12-02 Feng Xue <fxue@os.amperecomputing.com>
PR ipa/92133
* gcc.dg/ipa/ipa-clone-2.c: New test.
2019-12-01 Sandra Loosemore <sandra@codesourcery.com>
PR target/92499
......
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-ipa-cp-details -fno-early-inlining --param ipa-cp-max-recursive-depth=8" } */
int fn();
int data[100];
int recur_fn (int i)
{
int j;
if (i == 6)
{
fn();
fn();
fn();
fn();
fn();
fn();
fn();
fn();
fn();
fn();
fn();
fn();
return 10;
}
data[i] = i;
for (j = 0; j < 100; j++)
recur_fn (i + 1);
return i;
}
int main ()
{
int i;
for (i = 0; i < 100; i++)
recur_fn (1) + recur_fn (-5);
return 1;
}
/* { dg-final { scan-ipa-dump-times "Creating a specialized node of recur_fn/\[0-9\]*\\." 12 "cp" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment