On 3/30/23 09:41, Jakub Jelinek wrote:
On Wed, Mar 29, 2023 at 01:22:27PM -0400, Andrew MacLeod wrote:
however, as seems to be the case often, better ranges result in, I now get:
FAIL: 23_containers/vector/bool/allocator/copy.cc (test for excess errors)
Our middle-end warnings are just badly designed :(, the better value ranges
are, the more false positives they have.
commit 358d0ca44faf2e20fbacd0f74386308b5ca52cd4
Author: Andrew MacLeod <amacl...@redhat.com>
Date: Tue Mar 28 12:16:34 2023 -0400
Add recursive GORI recompuations with a depth limit.
LGTM for trunk, let's do with the regression incrementally.
Or as Richard mentioned on IRC, one possibility would be to force this
param temporarily to 1 (or whatever matches previous behavior) for the
diagnostic range queries).
You need a ChangeLog entry though...
Attached. I also removed the bogus warning in Walloc-13.c that no longer
happens
So incrementally deal with it.. what? just let it fail?
Andrew
commit debb8ce1f9b9d5a72d88d0ae90a6b4da5130ff59
Author: Andrew MacLeod <amacl...@redhat.com>
Date: Tue Mar 28 12:16:34 2023 -0400
Add recursive GORI recompuations with a depth limit.
PR tree-optimization/109154
gcc/
* gimple-range-gori.cc (gori_compute::may_recompute_p): Add depth limit.
* gimple-range-gori.h (may_recompute_p): Add depth param.
* params.opt (ranger-recompute-depth): New param.
gcc/testsuite/
* gcc.dg/Walloca-13.c: Remove bogus warning that is now fixed.
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 6e8dfa85ca8..5f4313b27dd 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -1308,7 +1308,7 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r,
// direct dependent is exported, it may also change the computed value of NAME.
bool
-gori_compute::may_recompute_p (tree name, basic_block bb)
+gori_compute::may_recompute_p (tree name, basic_block bb, int depth)
{
tree dep1 = depend1 (name);
tree dep2 = depend2 (name);
@@ -1322,22 +1322,36 @@ gori_compute::may_recompute_p (tree name, basic_block bb)
if (is_a<gphi *> (s) || gimple_has_side_effects (s))
return false;
- // If edge is specified, check if NAME can be recalculated on that edge.
- if (bb)
- return ((is_export_p (dep1, bb))
- || (dep2 && is_export_p (dep2, bb)));
+ if (!dep2)
+ {
+ // -1 indicates a default param, convert it to the real default.
+ if (depth == -1)
+ {
+ depth = (int)param_ranger_recompute_depth;
+ gcc_checking_assert (depth >= 1);
+ }
- return (is_export_p (dep1)) || (dep2 && is_export_p (dep2));
+ bool res = (bb ? is_export_p (dep1, bb) : is_export_p (dep1));
+ if (res || depth <= 1)
+ return res;
+ // Check another level of recomputation.
+ return may_recompute_p (dep1, bb, --depth);
+ }
+ // Two dependencies terminate the depth of the search.
+ if (bb)
+ return is_export_p (dep1, bb) || is_export_p (dep2, bb);
+ else
+ return is_export_p (dep1) || is_export_p (dep2);
}
// Return TRUE if NAME can be recomputed on edge E. If any direct dependent
// is exported on edge E, it may change the computed value of NAME.
bool
-gori_compute::may_recompute_p (tree name, edge e)
+gori_compute::may_recompute_p (tree name, edge e, int depth)
{
gcc_checking_assert (e);
- return may_recompute_p (name, e->src);
+ return may_recompute_p (name, e->src, depth);
}
diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h
index 0fc90ec8a18..3ea4b45595b 100644
--- a/gcc/gimple-range-gori.h
+++ b/gcc/gimple-range-gori.h
@@ -172,8 +172,8 @@ private:
bool refine_using_relation (tree op1, vrange &op1_range,
tree op2, vrange &op2_range,
fur_source &src, relation_kind k);
- bool may_recompute_p (tree name, edge e);
- bool may_recompute_p (tree name, basic_block bb = NULL);
+ bool may_recompute_p (tree name, edge e, int depth = -1);
+ bool may_recompute_p (tree name, basic_block bb = NULL, int depth = -1);
bool compute_operand_range_switch (vrange &r, gswitch *s, const vrange &lhs,
tree name, fur_source &src);
bool compute_operand1_range (vrange &r, gimple_range_op_handler &handler,
diff --git a/gcc/params.opt b/gcc/params.opt
index 2329d150ef0..b2ec436546c 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -900,6 +900,11 @@ Common Joined UInteger Var(param_ranger_logical_depth) Init(6) IntegerRange(1, 9
Maximum depth of logical expression evaluation ranger will look through when
evaluating outgoing edge ranges.
+-param=ranger-recompute-depth=
+Common Joined UInteger Var(param_ranger_recompute_depth) Init(5) IntegerRange(1, 100) Param Optimization
+Maximum depth of instruction chains to consider for recomputation in the
+outgoing range calculator.
+
-param=relation-block-limit=
Common Joined UInteger Var(param_relation_block_limit) Init(200) IntegerRange(0, 9999) Param Optimization
Maximum number of relations the oracle will register in a basic block.
diff --git a/gcc/testsuite/gcc.dg/Walloca-13.c b/gcc/testsuite/gcc.dg/Walloca-13.c
index 99d62065e26..d3af0c50399 100644
--- a/gcc/testsuite/gcc.dg/Walloca-13.c
+++ b/gcc/testsuite/gcc.dg/Walloca-13.c
@@ -8,5 +8,5 @@ void g (int *p, int *q)
{
__SIZE_TYPE__ n = (__SIZE_TYPE__)(p - q);
if (n < 100)
- f (__builtin_alloca (n)); // { dg-bogus "may be too large" "" { xfail { *-*-* } } }
+ f (__builtin_alloca (n));
}