public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Disable tbaa for some call to call_may_clobber_ref_p
@ 2020-10-08 13:53 Jan Hubicka
  2020-10-08 13:55 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2020-10-08 13:53 UTC (permalink / raw)
  To: gcc-patches, rguenther

Hi,
as discussed on IRC, I am testing the attached patch to disable TBAA for
some uses of call_may_clobber_ref_p.

OK if testing passes?

Honza

gcc/ChangeLog:

2020-10-08  Jan Hubicka  <hubicka@ucw.cz>

	* tree-nrv.c (dest_safe_for_nrv_p): Disable tbaa in 
	call_may_clobber_ref_p and ref_maybe_used_by_stmt_p.
	* tree-tailcall.c (find_tail_calls): Likewise.
	* tree-ssa-alias.c (call_may_clobber_ref_p): Add tbaa_p parameter.
	* tree-ssa-alias.h (call_may_clobber_ref_p): Update prototype.
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Pass data->tbaa_p
	to call_may_clobber_ref_p_1.

diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
index 9d17a104f34..df757f70e71 100644
--- a/gcc/tree-nrv.c
+++ b/gcc/tree-nrv.c
@@ -315,8 +315,8 @@ dest_safe_for_nrv_p (gcall *call)
   if (TREE_CODE (dest) == SSA_NAME)
     return true;
 
-  if (call_may_clobber_ref_p (call, dest)
-      || ref_maybe_used_by_stmt_p (call, dest))
+  if (call_may_clobber_ref_p (call, dest, false)
+      || ref_maybe_used_by_stmt_p (call, dest, false))
     return false;
 
   return true;
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 97255987e79..ac7e020c5e2 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -3320,12 +3320,12 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p)
    return true, otherwise return false.  */
 
 bool
-call_may_clobber_ref_p (gcall *call, tree ref)
+call_may_clobber_ref_p (gcall *call, tree ref, bool tbaa_p)
 {
   bool res;
   ao_ref r;
   ao_ref_init (&r, ref);
-  res = call_may_clobber_ref_p_1 (call, &r, true);
+  res = call_may_clobber_ref_p_1 (call, &r, tbaa_p);
   if (res)
     ++alias_stats.call_may_clobber_ref_p_may_alias;
   else
diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
index 1dd02c0ea62..1561ead2941 100644
--- a/gcc/tree-ssa-alias.h
+++ b/gcc/tree-ssa-alias.h
@@ -128,7 +128,7 @@ extern bool ref_maybe_used_by_stmt_p (gimple *, ao_ref *, bool = true);
 extern bool stmt_may_clobber_global_p (gimple *);
 extern bool stmt_may_clobber_ref_p (gimple *, tree, bool = true);
 extern bool stmt_may_clobber_ref_p_1 (gimple *, ao_ref *, bool = true);
-extern bool call_may_clobber_ref_p (gcall *, tree);
+extern bool call_may_clobber_ref_p (gcall *, tree, bool = true);
 extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *, bool = true);
 extern bool stmt_kills_ref_p (gimple *, tree);
 extern bool stmt_kills_ref_p (gimple *, ao_ref *);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 014b7bdfd01..c139adb6130 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2586,7 +2586,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
       if (valueized_anything)
 	{
 	  bool res = call_may_clobber_ref_p_1 (as_a <gcall *> (def_stmt),
-					       ref);
+					       ref, data->tbaa_p);
 	  for (unsigned i = 0; i < gimple_call_num_args (def_stmt); ++i)
 	    gimple_call_set_arg (def_stmt, i, oldargs[i]);
 	  if (!res)
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index d81e9213460..44643bef5f1 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -523,7 +523,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
   tree result_decl = DECL_RESULT (cfun->decl);
   if (result_decl
       && may_be_aliased (result_decl)
-      && ref_maybe_used_by_stmt_p (call, result_decl))
+      && ref_maybe_used_by_stmt_p (call, result_decl, false))
     return;
 
   /* We found the call, check whether it is suitable.  */
@@ -597,8 +597,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
       if (TREE_CODE (var) != PARM_DECL
 	  && auto_var_in_fn_p (var, cfun->decl)
 	  && may_be_aliased (var)
-	  && (ref_maybe_used_by_stmt_p (call, var)
-	      || call_may_clobber_ref_p (call, var)))
+	  && (ref_maybe_used_by_stmt_p (call, var, false)
+	      || call_may_clobber_ref_p (call, var, false)))
 	{
 	  if (!VAR_P (var))
 	    {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Disable tbaa for some call to call_may_clobber_ref_p
  2020-10-08 13:53 Disable tbaa for some call to call_may_clobber_ref_p Jan Hubicka
@ 2020-10-08 13:55 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2020-10-08 13:55 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches

On Thu, 8 Oct 2020, Jan Hubicka wrote:

> Hi,
> as discussed on IRC, I am testing the attached patch to disable TBAA for
> some uses of call_may_clobber_ref_p.
> 
> OK if testing passes?

OK.

Thanks,
Richard.

> Honza
> 
> gcc/ChangeLog:
> 
> 2020-10-08  Jan Hubicka  <hubicka@ucw.cz>
> 
> 	* tree-nrv.c (dest_safe_for_nrv_p): Disable tbaa in 
> 	call_may_clobber_ref_p and ref_maybe_used_by_stmt_p.
> 	* tree-tailcall.c (find_tail_calls): Likewise.
> 	* tree-ssa-alias.c (call_may_clobber_ref_p): Add tbaa_p parameter.
> 	* tree-ssa-alias.h (call_may_clobber_ref_p): Update prototype.
> 	* tree-ssa-sccvn.c (vn_reference_lookup_3): Pass data->tbaa_p
> 	to call_may_clobber_ref_p_1.
> 
> diff --git a/gcc/tree-nrv.c b/gcc/tree-nrv.c
> index 9d17a104f34..df757f70e71 100644
> --- a/gcc/tree-nrv.c
> +++ b/gcc/tree-nrv.c
> @@ -315,8 +315,8 @@ dest_safe_for_nrv_p (gcall *call)
>    if (TREE_CODE (dest) == SSA_NAME)
>      return true;
>  
> -  if (call_may_clobber_ref_p (call, dest)
> -      || ref_maybe_used_by_stmt_p (call, dest))
> +  if (call_may_clobber_ref_p (call, dest, false)
> +      || ref_maybe_used_by_stmt_p (call, dest, false))
>      return false;
>  
>    return true;
> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> index 97255987e79..ac7e020c5e2 100644
> --- a/gcc/tree-ssa-alias.c
> +++ b/gcc/tree-ssa-alias.c
> @@ -3320,12 +3320,12 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p)
>     return true, otherwise return false.  */
>  
>  bool
> -call_may_clobber_ref_p (gcall *call, tree ref)
> +call_may_clobber_ref_p (gcall *call, tree ref, bool tbaa_p)
>  {
>    bool res;
>    ao_ref r;
>    ao_ref_init (&r, ref);
> -  res = call_may_clobber_ref_p_1 (call, &r, true);
> +  res = call_may_clobber_ref_p_1 (call, &r, tbaa_p);
>    if (res)
>      ++alias_stats.call_may_clobber_ref_p_may_alias;
>    else
> diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
> index 1dd02c0ea62..1561ead2941 100644
> --- a/gcc/tree-ssa-alias.h
> +++ b/gcc/tree-ssa-alias.h
> @@ -128,7 +128,7 @@ extern bool ref_maybe_used_by_stmt_p (gimple *, ao_ref *, bool = true);
>  extern bool stmt_may_clobber_global_p (gimple *);
>  extern bool stmt_may_clobber_ref_p (gimple *, tree, bool = true);
>  extern bool stmt_may_clobber_ref_p_1 (gimple *, ao_ref *, bool = true);
> -extern bool call_may_clobber_ref_p (gcall *, tree);
> +extern bool call_may_clobber_ref_p (gcall *, tree, bool = true);
>  extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *, bool = true);
>  extern bool stmt_kills_ref_p (gimple *, tree);
>  extern bool stmt_kills_ref_p (gimple *, ao_ref *);
> diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
> index 014b7bdfd01..c139adb6130 100644
> --- a/gcc/tree-ssa-sccvn.c
> +++ b/gcc/tree-ssa-sccvn.c
> @@ -2586,7 +2586,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
>        if (valueized_anything)
>  	{
>  	  bool res = call_may_clobber_ref_p_1 (as_a <gcall *> (def_stmt),
> -					       ref);
> +					       ref, data->tbaa_p);
>  	  for (unsigned i = 0; i < gimple_call_num_args (def_stmt); ++i)
>  	    gimple_call_set_arg (def_stmt, i, oldargs[i]);
>  	  if (!res)
> diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
> index d81e9213460..44643bef5f1 100644
> --- a/gcc/tree-tailcall.c
> +++ b/gcc/tree-tailcall.c
> @@ -523,7 +523,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
>    tree result_decl = DECL_RESULT (cfun->decl);
>    if (result_decl
>        && may_be_aliased (result_decl)
> -      && ref_maybe_used_by_stmt_p (call, result_decl))
> +      && ref_maybe_used_by_stmt_p (call, result_decl, false))
>      return;
>  
>    /* We found the call, check whether it is suitable.  */
> @@ -597,8 +597,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
>        if (TREE_CODE (var) != PARM_DECL
>  	  && auto_var_in_fn_p (var, cfun->decl)
>  	  && may_be_aliased (var)
> -	  && (ref_maybe_used_by_stmt_p (call, var)
> -	      || call_may_clobber_ref_p (call, var)))
> +	  && (ref_maybe_used_by_stmt_p (call, var, false)
> +	      || call_may_clobber_ref_p (call, var, false)))
>  	{
>  	  if (!VAR_P (var))
>  	    {
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imend

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-08 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 13:53 Disable tbaa for some call to call_may_clobber_ref_p Jan Hubicka
2020-10-08 13:55 ` Richard Biener

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