* [PATCH] tree-cfg: Move the returns_twice check to be last statement only [PR114301]
@ 2024-05-14 15:51 Andrew Pinski
2024-05-15 8:02 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2024-05-14 15:51 UTC (permalink / raw)
To: gcc-patches; +Cc: Andrew Pinski
When I was checking to making sure that all of the bugs dealing
with the case where gimple_can_duplicate_bb_p would return false was fixed,
I noticed that the code which was checking if a call statement was
returns_twice was checking all call statements rather than just the
last statement. Since calling gimple_call_flags has a small non-zero
overhead due to a few string comparison, removing the uses of it
can have a small performance improvement. In the case of returns_twice
functions calls, will always end the basic-block due to the check in
stmt_can_terminate_bb_p (and others). So checking only the last statement
is a small optimization and will be safe.
Bootstrapped and tested pon x86_64-linux-gnu with no regressions.
PR tree-optimization/114301
gcc/ChangeLog:
* tree-cfg.cc (gimple_can_duplicate_bb_p): Check returns_twice
only on the last call statement rather than all.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
gcc/tree-cfg.cc | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index b2d47b72084..7fb7b92966b 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -6495,6 +6495,13 @@ gimple_can_duplicate_bb_p (const_basic_block bb)
&& gimple_call_internal_p (last)
&& gimple_call_internal_unique_p (last))
return false;
+
+ /* Prohibit duplication of returns_twice calls, otherwise associated
+ abnormal edges also need to be duplicated properly.
+ return_twice functions will always be the last statement. */
+ if (is_gimple_call (last)
+ && (gimple_call_flags (last) & ECF_RETURNS_TWICE))
+ return false;
}
for (gimple_stmt_iterator gsi = gsi_start_bb (CONST_CAST_BB (bb));
@@ -6502,15 +6509,12 @@ gimple_can_duplicate_bb_p (const_basic_block bb)
{
gimple *g = gsi_stmt (gsi);
- /* Prohibit duplication of returns_twice calls, otherwise associated
- abnormal edges also need to be duplicated properly.
- An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be
+ /* An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be
duplicated as part of its group, or not at all.
The IFN_GOMP_SIMT_VOTE_ANY and IFN_GOMP_SIMT_XCHG_* are part of such a
group, so the same holds there. */
if (is_gimple_call (g)
- && (gimple_call_flags (g) & ECF_RETURNS_TWICE
- || gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC)
+ && (gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC)
|| gimple_call_internal_p (g, IFN_GOMP_SIMT_EXIT)
|| gimple_call_internal_p (g, IFN_GOMP_SIMT_VOTE_ANY)
|| gimple_call_internal_p (g, IFN_GOMP_SIMT_XCHG_BFLY)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tree-cfg: Move the returns_twice check to be last statement only [PR114301]
2024-05-14 15:51 [PATCH] tree-cfg: Move the returns_twice check to be last statement only [PR114301] Andrew Pinski
@ 2024-05-15 8:02 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-05-15 8:02 UTC (permalink / raw)
To: Andrew Pinski; +Cc: gcc-patches
On Tue, May 14, 2024 at 5:52 PM Andrew Pinski <quic_apinski@quicinc.com> wrote:
>
> When I was checking to making sure that all of the bugs dealing
> with the case where gimple_can_duplicate_bb_p would return false was fixed,
> I noticed that the code which was checking if a call statement was
> returns_twice was checking all call statements rather than just the
> last statement. Since calling gimple_call_flags has a small non-zero
> overhead due to a few string comparison, removing the uses of it
> can have a small performance improvement. In the case of returns_twice
> functions calls, will always end the basic-block due to the check in
> stmt_can_terminate_bb_p (and others). So checking only the last statement
> is a small optimization and will be safe.
>
> Bootstrapped and tested pon x86_64-linux-gnu with no regressions.
OK.
> PR tree-optimization/114301
> gcc/ChangeLog:
>
> * tree-cfg.cc (gimple_can_duplicate_bb_p): Check returns_twice
> only on the last call statement rather than all.
>
> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
> ---
> gcc/tree-cfg.cc | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
> index b2d47b72084..7fb7b92966b 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -6495,6 +6495,13 @@ gimple_can_duplicate_bb_p (const_basic_block bb)
> && gimple_call_internal_p (last)
> && gimple_call_internal_unique_p (last))
> return false;
> +
> + /* Prohibit duplication of returns_twice calls, otherwise associated
> + abnormal edges also need to be duplicated properly.
> + return_twice functions will always be the last statement. */
> + if (is_gimple_call (last)
> + && (gimple_call_flags (last) & ECF_RETURNS_TWICE))
> + return false;
> }
>
> for (gimple_stmt_iterator gsi = gsi_start_bb (CONST_CAST_BB (bb));
> @@ -6502,15 +6509,12 @@ gimple_can_duplicate_bb_p (const_basic_block bb)
> {
> gimple *g = gsi_stmt (gsi);
>
> - /* Prohibit duplication of returns_twice calls, otherwise associated
> - abnormal edges also need to be duplicated properly.
> - An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be
> + /* An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be
> duplicated as part of its group, or not at all.
> The IFN_GOMP_SIMT_VOTE_ANY and IFN_GOMP_SIMT_XCHG_* are part of such a
> group, so the same holds there. */
> if (is_gimple_call (g)
> - && (gimple_call_flags (g) & ECF_RETURNS_TWICE
> - || gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC)
> + && (gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC)
> || gimple_call_internal_p (g, IFN_GOMP_SIMT_EXIT)
> || gimple_call_internal_p (g, IFN_GOMP_SIMT_VOTE_ANY)
> || gimple_call_internal_p (g, IFN_GOMP_SIMT_XCHG_BFLY)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-15 8:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 15:51 [PATCH] tree-cfg: Move the returns_twice check to be last statement only [PR114301] Andrew Pinski
2024-05-15 8:02 ` 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).