public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: kugan <kugan.vivekanandarajah@linaro.org>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Richard Biener <richard.guenther@gmail.com>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [RFC][IPA-VRP] Add support for IPA VRP in ipa-cp/ipa-prop
Date: Thu, 21 Jul 2016 12:54:00 -0000	[thread overview]
Message-ID: <20160721125416.GA23760@kam.mff.cuni.cz> (raw)
In-Reply-To: <578E9B16.2080100@linaro.org>

> Maybe it is better to separate value range and alignment summary
> writing/reading to different functions. Here is another updated
> version which does this.

Makes sense to me. Note that the alignment summary propagation can be either
handled by doing bitwise constant propagation and/or extending our value ranges
by stride (as described in
http://www.lighterra.com/papers/valuerangeprop/Patterson1995-ValueRangeProp.pdf
I would like it to go eventually away in favour of more generic solution.

> -/* If DEST_PLATS already has aggregate items, check that aggs_by_ref matches
> +/* Propagate value range across jump function JFUNC that is associated with
> +   edge CS and update DEST_PLATS accordingly.  */
> +
> +static bool
> +propagate_vr_accross_jump_function (cgraph_edge *cs,
> +				    ipa_jump_func *jfunc,
> +				    struct ipcp_param_lattices *dest_plats)
> +{
> +  struct ipcp_param_lattices *src_lats;
> +  ipcp_vr_lattice *dest_lat = &dest_plats->m_value_range;
> +
> +  if (dest_lat->bottom_p ())
> +    return false;
> +
> +  if (jfunc->type == IPA_JF_PASS_THROUGH)
> +    {
> +      struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
> +      int src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
> +      src_lats = ipa_get_parm_lattices (caller_info, src_idx);
> +
> +      if (ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
> +	return dest_lat->meet_with (src_lats->m_value_range);

Clearly we can propagate thorugh expressions here (PLUS_EXPR). I have run
into similar issue in loop code that builds simple generic expresisons
(like (int)ssa_name+10) and it would be nice to have easy way to deterine
their value range based on the knowledge of SSA_NAME's valur range.

Bit this is fine for initial implementaiotn for sure.
>  
> +/* Look up all VR information that we have discovered and copy it over
> +   to the transformation summary.  */
> +
> +static void
> +ipcp_store_vr_results (void)
> +{
> +  cgraph_node *node;
> +
> +  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
> +  {
> +    ipa_node_params *info = IPA_NODE_REF (node);
> +    bool found_useful_result = false;
> +
> +    if (!opt_for_fn (node->decl, flag_ipa_vrp))
> +      {
> +	if (dump_file)
> +	  fprintf (dump_file, "Not considering %s for VR discovery "
> +		   "and propagate; -fipa-ipa-vrp: disabled.\n",
> +		   node->name ());
> +	continue;

I belive you need to also prevent propagation through functions copmiled with
-fno-ipa-vrp, not only prevent any transformations.
> +/* Update value range of formal parameters as described in
> +   ipcp_transformation_summary.  */
> +
> +static void
> +ipcp_update_vr (struct cgraph_node *node)
> +{
> +  tree fndecl = node->decl;
> +  tree parm = DECL_ARGUMENTS (fndecl);
> +  tree next_parm = parm;
> +  ipcp_transformation_summary *ts = ipcp_get_transformation_summary (node);
> +  if (!ts || vec_safe_length (ts->m_vr) == 0)
> +    return;
> +  const vec<ipa_vr, va_gc> &vr = *ts->m_vr;
> +  unsigned count = vr.length ();
> +
> +  for (unsigned i = 0; i < count; ++i, parm = next_parm)
> +    {
> +      if (node->clone.combined_args_to_skip
> +	  && bitmap_bit_p (node->clone.combined_args_to_skip, i))
> +	continue;
> +      gcc_checking_assert (parm);
> +      next_parm = DECL_CHAIN (parm);
> +      tree ddef = ssa_default_def (DECL_STRUCT_FUNCTION (node->decl), parm);
> +
> +      if (!ddef || !is_gimple_reg (parm))
> +	continue;
> +
> +      if (cgraph_local_p (node)
The test of cgraph_local_p seems redundant here. The analysis phase should not determine
anything if function is reachable non-locally.
> +/* Info about value ranges.  */
> +
> +struct GTY(()) ipa_vr
> +{
> +  /* The data fields below are valid only if known is true.  */
> +  bool known;
> +  enum value_range_type type;
> +  tree min;
> +  tree max;
What is the point of representing range as trees rather than wide ints. Can they
be non-constant integer?

The patch looks good to me otherwise!
Honza

  reply	other threads:[~2016-07-21 12:54 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15  4:41 [RFC][IPA-VRP] IPA VRP Implementation kugan
2016-07-15  4:42 ` [RFC][IPA-VRP] Disable setting param of __builtin_constant_p to null kugan
2016-07-15  8:43   ` Jan Hubicka
2016-07-25  6:59     ` kugan
2016-07-25 10:02       ` Richard Biener
2016-07-15  4:43 ` [RFC][IPA-VRP] Check for POINTER_TYPE_P before accessing SSA_NAME_PTR_INFO in tree-inline kugan
2016-07-15  4:47   ` Andrew Pinski
2016-07-15  7:03     ` kugan
2016-07-15  7:03     ` Jakub Jelinek
2016-07-15  7:32   ` Richard Biener
2016-07-15  4:44 ` [RFC][IPA-VRP] Re-factor tree-vrp to factor out common code kugan
2016-07-15  4:47   ` [RFC][IPA-VRP] Add support for IPA VRP in ipa-cp/ipa-prop kugan
2016-07-15 12:23     ` Martin Jambor
2016-07-19  8:22       ` kugan
2016-07-19 21:27         ` kugan
2016-07-21 12:54           ` Jan Hubicka [this message]
2016-08-30  5:21             ` Kugan Vivekanandarajah
2016-08-30 18:12               ` Prathamesh Kulkarni
2016-08-30 21:10                 ` kugan
2016-09-02 12:31               ` Jan Hubicka
2016-07-17 13:24     ` Prathamesh Kulkarni
2016-07-22 12:27   ` [RFC][IPA-VRP] Re-factor tree-vrp to factor out common code kugan
2016-07-22 12:49     ` Richard Biener
2016-07-22 14:34       ` kugan
2016-07-23 10:12         ` kugan
2016-08-16  8:09           ` kugan
2016-08-16 11:56             ` Richard Biener
2016-08-16 22:20               ` kugan
2016-08-17  2:50                 ` kugan
2016-08-17 13:46                   ` Richard Biener
2016-07-15  4:45 ` [RFC][IPA-VRP] Early VRP Implementation kugan
2016-07-15  4:52   ` Andrew Pinski
2016-07-15  7:08     ` kugan
2016-07-15  7:28       ` Andrew Pinski
2016-07-15  7:33         ` kugan
2016-07-18 11:51           ` Richard Biener
2016-07-22 12:10             ` kugan
2016-07-25 11:18               ` Richard Biener
2016-07-26 12:27                 ` kugan
2016-07-26 13:37                   ` Richard Biener
2016-07-28  7:36                     ` kugan
2016-07-28 11:34                       ` Richard Biener
2016-08-03  1:17                         ` kugan
2016-08-12 10:43                           ` Richard Biener
2016-08-16  7:39                             ` [RFC][IPA-VRP] splits out the update_value_range calls from vrp_visit_stmt kugan
2016-08-16 10:58                               ` Richard Biener
2016-08-17  2:27                                 ` kugan
2016-08-17 13:44                                   ` Richard Biener
2016-08-16  7:45                             ` [RFC][IPA-VRP] Early VRP Implementation kugan
2016-08-19 11:41                               ` Richard Biener
2016-08-23  2:12                                 ` Kugan Vivekanandarajah
2016-09-02  8:11                                   ` Kugan Vivekanandarajah
2016-09-14 12:11                                   ` Richard Biener
2016-09-14 21:47                                     ` Jan Hubicka
2016-09-15  7:23                                       ` Richard Biener
2016-09-15 14:57                                         ` Jeff Law
2016-09-16  8:59                                           ` Richard Biener
2016-09-16  6:37                                     ` kugan
2016-09-16 10:26                                       ` Richard Biener
2016-09-18 23:40                                         ` kugan
2016-09-19 13:30                                           ` Richard Biener
2016-09-20  5:48                                             ` kugan
2016-07-19 16:19     ` Jeff Law
2016-07-19 18:35       ` Richard Biener
2016-07-19 20:14         ` Jeff Law
2016-07-15  4:47 ` [RFC][IPA-VRP] Teach tree-vrp to use the VR set in params kugan
2016-07-18 11:33   ` Richard Biener

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=20160721125416.GA23760@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kugan.vivekanandarajah@linaro.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).