public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Andrew MacLeod <amacleod@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>,
	"hernandez, aldy" <aldyh@redhat.com>
Subject: Re: recomputation and PR 109154
Date: Thu, 30 Mar 2023 15:41:39 +0200	[thread overview]
Message-ID: <ZCWRk35kfgM2+Inl@tucnak> (raw)
In-Reply-To: <54bb3bc9-e0c1-b5ab-4447-5908b09fd19f@redhat.com>

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 <amacleod@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...

> 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.


	Jakub


  parent reply	other threads:[~2023-03-30 13:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 17:22 Andrew MacLeod
2023-03-30  6:42 ` Richard Biener
2023-03-30 13:41 ` Jakub Jelinek [this message]
2023-03-30 15:58   ` Andrew MacLeod
2023-03-30 16:05     ` Jakub Jelinek
2023-03-30 20:39       ` Andrew MacLeod
2023-03-31  6:08         ` Andrew Pinski
2023-03-31 16:12     ` Regression with "recomputation and PR 109154" Hans-Peter Nilsson
2023-03-31 16:20       ` Jeff Law
2023-03-31 17:02         ` Andrew MacLeod
2023-03-31 17:37           ` Jakub Jelinek
2023-03-31 19:48             ` Andrew MacLeod
2023-03-31 19:59               ` Jeff Law
2023-03-31 20:16                 ` Andrew MacLeod
2023-03-31 20:20                   ` Jeff Law
2023-03-31 23:31               ` Hans-Peter Nilsson
2023-04-01  1:11                 ` Andrew MacLeod

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCWRk35kfgM2+Inl@tucnak \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).