diff mbox series

Fix small thinko in IPA mod/ref pass

Message ID 6084877.lOV4Wx5bFT@fomalhaut
State New
Headers show
Series Fix small thinko in IPA mod/ref pass | expand

Commit Message

Eric Botcazou Sept. 20, 2024, 9:10 a.m. UTC
Hi,

the attached C testcase exhibits a wrong-code regression present since the 
specific support for the static chain was added to the IPA mod/ref pass (GCC 
12 and later) although the underlying issue might have been present before.

When a memory copy operation is analyzed by analyze_ssa_name, if both the load 
and the store are made through the same SSA name, the store is overlooked.

Tested on x86-64/Linux, OK for all active branches?


2024-09-20  Eric Botcazou  <ebotcazou@adacore.com>

	* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always
	process both the load and the store of a memory copy operation.


2024-09-20  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/ipa/modref-4.c: New test.

Comments

Richard Biener Sept. 20, 2024, 10:16 a.m. UTC | #1
On Fri, Sep 20, 2024 at 11:12 AM Eric Botcazou <botcazou@adacore.com> wrote:
>
> Hi,
>
> the attached C testcase exhibits a wrong-code regression present since the
> specific support for the static chain was added to the IPA mod/ref pass (GCC
> 12 and later) although the underlying issue might have been present before.
>
> When a memory copy operation is analyzed by analyze_ssa_name, if both the load
> and the store are made through the same SSA name, the store is overlooked.

Whoops...

> Tested on x86-64/Linux, OK for all active branches?

OK.

Thanks,
Richard.

>
> 2024-09-20  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always
>         process both the load and the store of a memory copy operation.
>
>
> 2024-09-20  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gcc.dg/ipa/modref-4.c: New test.
>
> --
> Eric Botcazou
diff mbox series

Patch

diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index 9275030c254..400a8856de2 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -2610,8 +2610,9 @@  modref_eaf_analysis::analyze_ssa_name (tree name, bool deferred)
 		 is used arbitrarily.  */
 	      if (memory_access_to (gimple_assign_rhs1 (assign), name))
 		m_lattice[index].merge (deref_flags (0, false));
+
 	      /* Handle *name = *exp.  */
-	      else if (memory_access_to (gimple_assign_lhs (assign), name))
+	      if (memory_access_to (gimple_assign_lhs (assign), name))
 		m_lattice[index].merge_direct_store ();
 	    }
 	  /* Handle lhs = *name.  */