public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Li, Pan2" <pan2.li@intel.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>,
	"kito.cheng@sifive.com" <kito.cheng@sifive.com>,
	"Wang, Yanzhang" <yanzhang.wang@intel.com>,
	"jeffreyalaw@gmail.com" <jeffreyalaw@gmail.com>,
	"rguenther@suse.de" <rguenther@suse.de>,
	"richard.sandiford@arm.com" <richard.sandiford@arm.com>
Subject: RE: [PATCH] Var-Tracking: Leverage pointer_mux for decl_or_value
Date: Wed, 10 May 2023 11:59:14 +0000	[thread overview]
Message-ID: <MW5PR11MB59084B732ED74A54A78A63A5A9779@MW5PR11MB5908.namprd11.prod.outlook.com> (raw)
In-Reply-To: <ZFtSOGtqdNIxdvuF@tucnak>

Thanks all for comments.

Looks like pay too much attention for the NULL check but it is covered by pointer_mux already. Update PATCH v2 as below, please help to review continuously.

https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618007.html

Pan

-----Original Message-----
From: Jakub Jelinek <jakub@redhat.com> 
Sent: Wednesday, May 10, 2023 4:14 PM
To: Li, Pan2 <pan2.li@intel.com>
Cc: gcc-patches@gcc.gnu.org; juzhe.zhong@rivai.ai; kito.cheng@sifive.com; Wang, Yanzhang <yanzhang.wang@intel.com>; jeffreyalaw@gmail.com; rguenther@suse.de; richard.sandiford@arm.com
Subject: Re: [PATCH] Var-Tracking: Leverage pointer_mux for decl_or_value

On Wed, May 10, 2023 at 03:17:58PM +0800, Pan Li via Gcc-patches wrote:
> gcc/ChangeLog:
> 
> 	* var-tracking.cc (DECL_OR_VALUE_OR_DEFAULT): New macro for
> 	  clean code.

ChangeLog formatting shouldn't have spaces after the initial tab.
Furthermore, the entry doesn't describe what changes you've made.
It should start with:
	* var-tracking.cc: Include mux-utils.h.
	(decl_or_value): Changed from void * to
	pointer_mux<tree_node, rtx_def>.
	(DECL_OR_VALUE_OR_DEFAULT): Define.
etc.

> --- a/gcc/var-tracking.cc
> +++ b/gcc/var-tracking.cc
> @@ -116,9 +116,17 @@
>  #include "fibonacci_heap.h"
>  #include "print-rtl.h"
>  #include "function-abi.h"
> +#include "mux-utils.h"
>  
>  typedef fibonacci_heap <long, basic_block_def> bb_heap_t;
>  
> +/* A declaration of a variable, or an RTL value being handled like a
> +   declaration by pointer_mux.  */
> +typedef pointer_mux<tree_node, rtx_def> decl_or_value;
> +
> +#define DECL_OR_VALUE_OR_DEFAULT(ptr) \
> +  ((ptr) ? decl_or_value (ptr) : decl_or_value ())
> +
>  /* var-tracking.cc assumes that tree code with the same value as VALUE rtx code
>     has no chance to appear in REG_EXPR/MEM_EXPRs and isn't a decl.
>     Currently the value is the same as IDENTIFIER_NODE, which has such 
> @@ -196,15 +204,21 @@ struct micro_operation  };
>  
>  
> -/* A declaration of a variable, or an RTL value being handled like a
> -   declaration.  */
> -typedef void *decl_or_value;
> -
>  /* Return true if a decl_or_value DV is a DECL or NULL.  */  static 
> inline bool  dv_is_decl_p (decl_or_value dv)  {
> -  return !dv || (int) TREE_CODE ((tree) dv) != (int) VALUE;
> +  bool is_decl = !dv;
> +
> +  if (dv)
> +    {
> +      if (dv.is_first ())
> +	is_decl = (int) TREE_CODE (dv.known_first ()) != (int) VALUE;
> +      else if (!dv.is_first () && !dv.is_second ())
> +	is_decl = true;
> +    }
> +
> +  return is_decl;

I really don't understand why it needs to be so complicated.
decl_or_value is dv_is_decl_p if it is NULL or if it is a tree, and is false if it is rtx VALUE, no other rtxes are expected.
pointer_mux<tree_node, rtx_def> should accept nullptr as being the first one, so i'd expect just

/* Return true if a decl_or_value DV is a DECL or NULL.  */ static inline bool dv_is_decl_p (decl_or_value dv) {
  return dv.is_first ();
}

/* Return true if a decl_or_value is a VALUE rtl.  */ static inline bool dv_is_value_p (decl_or_value dv) {
  return dv.is_second ();
} 

/* Return the decl in the decl_or_value.  */ static inline tree dv_as_decl (decl_or_value dv) {
  gcc_checking_assert (dv_is_decl_p (dv));
  return dv.known_first ();
}
  
/* Return the value in the decl_or_value.  */ static inline rtx dv_as_value (decl_or_value dv) {
  gcc_checking_assert (dv_is_value_p (dv));
  return dv.known_second ();
}
   
/* Return the opaque pointer in the decl_or_value.  */ static inline void * dv_as_opaque (decl_or_value dv) {
  return dv.is_first () ? (void *) dv.known_first ()
			: (void *) dv.known_second ();
}

// Ideally dv_as_opaque would just return m_ptr but that // is unfortunately private.

And define a hasher for decl_or_value now that it is a class (that would hash/compare the m_ptr value or separately dv.is_first () bool and dv_as_opaque pointer).

And then I'd hope you don't need to do any further changes in the file.

	Jakub


  reply	other threads:[~2023-05-10 11:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10  7:17 pan2.li
2023-05-10  7:56 ` Richard Biener
2023-05-10  8:02   ` Richard Sandiford
2023-05-10  8:13 ` Jakub Jelinek
2023-05-10 11:59   ` Li, Pan2 [this message]
2023-05-10 11:57 ` [PATCH v2] Var-Tracking: Typedef pointer_mux<tree_node, rtx_def> as decl_or_value pan2.li
2023-05-10 12:22   ` Jakub Jelinek
2023-05-10 12:53     ` Richard Sandiford
2023-05-10 13:57       ` Li, Pan2
2023-05-10 15:23 ` [PATCH v3] " pan2.li
2023-05-10 15:55   ` Richard Sandiford
2023-05-11  2:30     ` Li, Pan2
2023-05-11  4:43       ` Richard Sandiford
2023-05-11  6:30         ` Li, Pan2
2023-05-11  6:31       ` Bernhard Reutner-Fischer
2023-05-11  2:28 ` [PATCH v4] " pan2.li
2023-05-11  6:21 ` [PATCH v5] " pan2.li
2023-05-11  7:16   ` Richard Sandiford
2023-05-11 10:55     ` Li, Pan2
2023-05-11 12:56       ` Li, Pan2
2023-05-11 12:54 ` [PATCH v6] " pan2.li

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=MW5PR11MB59084B732ED74A54A78A63A5A9779@MW5PR11MB5908.namprd11.prod.outlook.com \
    --to=pan2.li@intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jeffreyalaw@gmail.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=kito.cheng@sifive.com \
    --cc=rguenther@suse.de \
    --cc=richard.sandiford@arm.com \
    --cc=yanzhang.wang@intel.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).