[1/2] forwprop: Add a quick out for new_src_based_on_copy when both are decls

Message ID 20250916223125.3938555-1-andrew.pinski@oss.qualcomm.com
State Committed
Commit 4b83df548f3f16c8c5bd83d82801f8219984e089
Headers
Series [1/2] forwprop: Add a quick out for new_src_based_on_copy when both are decls |

Commit Message

Andrew Pinski Sept. 16, 2025, 10:31 p.m. UTC
  If both operands that are being compared are decls, operand_equal_p will already
handle that case so an early out can be done here.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* tree-ssa-forwprop.cc (new_src_based_on_copy): An early out
	if both are decls.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
---
 gcc/tree-ssa-forwprop.cc | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Richard Biener Sept. 17, 2025, 6:32 a.m. UTC | #1
On Wed, Sep 17, 2025 at 12:33 AM Andrew Pinski
<andrew.pinski@oss.qualcomm.com> wrote:
>
> If both operands that are being compared are decls, operand_equal_p will already
> handle that case so an early out can be done here.
>
> Bootstrapped and tested on x86_64-linux-gnu.


OK.
> gcc/ChangeLog:
>
>         * tree-ssa-forwprop.cc (new_src_based_on_copy): An early out
>         if both are decls.
>
> Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
> ---
>  gcc/tree-ssa-forwprop.cc | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
> index f58a7b8c591..9d389e1b9bf 100644
> --- a/gcc/tree-ssa-forwprop.cc
> +++ b/gcc/tree-ssa-forwprop.cc
> @@ -1473,6 +1473,10 @@ new_src_based_on_copy (tree src2, tree dest, tree src)
>       where one field is the same size as the whole struct.  */
>    if (operand_equal_p (dest, src2))
>      return src;
> +  /* if both dest and src2 are decls, then we know these 2
> +     accesses can't be the same.  */
> +  if (DECL_P (dest) && DECL_P (src2))
> +    return NULL_TREE;
>    /* A VCE can't be used with imag/real or BFR so reject them early. */
>    if (TREE_CODE (src) == IMAGPART_EXPR
>        || TREE_CODE (src) == REALPART_EXPR
> --
> 2.43.0
>
  

Patch

diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index f58a7b8c591..9d389e1b9bf 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1473,6 +1473,10 @@  new_src_based_on_copy (tree src2, tree dest, tree src)
      where one field is the same size as the whole struct.  */
   if (operand_equal_p (dest, src2))
     return src;
+  /* if both dest and src2 are decls, then we know these 2
+     accesses can't be the same.  */
+  if (DECL_P (dest) && DECL_P (src2))
+    return NULL_TREE;
   /* A VCE can't be used with imag/real or BFR so reject them early. */
   if (TREE_CODE (src) == IMAGPART_EXPR
       || TREE_CODE (src) == REALPART_EXPR