public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls
@ 2021-11-30 14:22 Martin Jambor
  2021-11-30 14:32 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Jambor @ 2021-11-30 14:22 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka

Hi,

in PR 103267 Honza found out that IPA-SRA does not look at
ECF_LOOPING_CONST_OR_PURE when evaluating if a call can have side
effects.  Fixed with this patch.  The testcase infinitely loops in a
const function, so it would not make a good addition to the testsuite.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


gcc/ChangeLog:

2021-11-29  Martin Jambor  <mjambor@suse.cz>

	PT ipa/103267
	* ipa-sra.c (scan_function): Also check ECF_LOOPING_CONST_OR_PURE flag.
---
 gcc/ipa-sra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c
index cb0e30507a1..12ccd049552 100644
--- a/gcc/ipa-sra.c
+++ b/gcc/ipa-sra.c
@@ -1925,7 +1925,8 @@ scan_function (cgraph_node *node, struct function *fun)
 		if (lhs)
 		  scan_expr_access (lhs, stmt, ISRA_CTX_STORE, bb);
 		int flags = gimple_call_flags (stmt);
-		if ((flags & (ECF_CONST | ECF_PURE)) == 0)
+		if (((flags & (ECF_CONST | ECF_PURE)) == 0)
+		    || (flags & ECF_LOOPING_CONST_OR_PURE))
 		  bitmap_set_bit (final_bbs, bb->index);
 	      }
 	      break;
-- 
2.33.1


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

* Re: [PATCH] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls
  2021-11-30 14:22 [PATCH] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls Martin Jambor
@ 2021-11-30 14:32 ` Richard Biener
  2021-12-01 17:29   ` Martin Jambor
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2021-11-30 14:32 UTC (permalink / raw)
  To: Martin Jambor; +Cc: GCC Patches, Jan Hubicka

On Tue, Nov 30, 2021 at 3:24 PM Martin Jambor <mjambor@suse.cz> wrote:
>
> Hi,
>
> in PR 103267 Honza found out that IPA-SRA does not look at
> ECF_LOOPING_CONST_OR_PURE when evaluating if a call can have side
> effects.  Fixed with this patch.  The testcase infinitely loops in a
> const function, so it would not make a good addition to the testsuite.
>
> Bootstrapped and tested on x86_64-linux.  OK for trunk?

OK.

> Thanks,
>
> Martin
>
>
> gcc/ChangeLog:
>
> 2021-11-29  Martin Jambor  <mjambor@suse.cz>
>
>         PT ipa/103267
>         * ipa-sra.c (scan_function): Also check ECF_LOOPING_CONST_OR_PURE flag.
> ---
>  gcc/ipa-sra.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c
> index cb0e30507a1..12ccd049552 100644
> --- a/gcc/ipa-sra.c
> +++ b/gcc/ipa-sra.c
> @@ -1925,7 +1925,8 @@ scan_function (cgraph_node *node, struct function *fun)
>                 if (lhs)
>                   scan_expr_access (lhs, stmt, ISRA_CTX_STORE, bb);
>                 int flags = gimple_call_flags (stmt);
> -               if ((flags & (ECF_CONST | ECF_PURE)) == 0)
> +               if (((flags & (ECF_CONST | ECF_PURE)) == 0)
> +                   || (flags & ECF_LOOPING_CONST_OR_PURE))
>                   bitmap_set_bit (final_bbs, bb->index);
>               }
>               break;
> --
> 2.33.1
>

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

* Re: [PATCH] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls
  2021-11-30 14:32 ` Richard Biener
@ 2021-12-01 17:29   ` Martin Jambor
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Jambor @ 2021-12-01 17:29 UTC (permalink / raw)
  To: GCC Patches

On Tue, Nov 30 2021, Richard Biener wrote:
> On Tue, Nov 30, 2021 at 3:24 PM Martin Jambor <mjambor@suse.cz> wrote:
>>
>> Hi,
>>
>> in PR 103267 Honza found out that IPA-SRA does not look at
>> ECF_LOOPING_CONST_OR_PURE when evaluating if a call can have side
>> effects.  Fixed with this patch.  The testcase infinitely loops in a
>> const function, so it would not make a good addition to the testsuite.
>>
>> Bootstrapped and tested on x86_64-linux.  OK for trunk?
>
> OK.
>

Thank you.  For reference, I am also about to commit (after having
bootstrapped and tested it on x86_64-linx) the following backport to the
old IPA-SRA we have in GCC 9.

Thanks,

Martin



gcc/ChangeLog:

2021-12-01  Martin Jambor  <mjambor@suse.cz>

	PR ipa/103267
	* tree-sra.c (scan_function): Also check ECF_LOOPING_CONST_OR_PURE
	flag.
---
 gcc/tree-sra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 909b4fef9a8..252953b7512 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1530,7 +1530,8 @@ scan_function (void)
 		    }
 
 		  if (final_bbs
-		      && (flags & (ECF_CONST | ECF_PURE)) == 0)
+		      && ((flags & (ECF_CONST | ECF_PURE)) == 0
+			  || (flags & ECF_LOOPING_CONST_OR_PURE)))
 		    bitmap_set_bit (final_bbs, bb->index);
 		}
 
-- 
2.33.1


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

end of thread, other threads:[~2021-12-01 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 14:22 [PATCH] ipa-sra: Check also ECF_LOOPING_CONST_OR_PURE when evaluating calls Martin Jambor
2021-11-30 14:32 ` Richard Biener
2021-12-01 17:29   ` Martin Jambor

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