Andrew Pinski 143bb738d4 phiprop: Allow for one store inbetween the load and the phi which is being used to insert [PR123120]
So phiprop has one disadvantage is that if there is store between the
phi with the addresses and the new load, phiprop will no do anything.
This means for some C++ code where you have a min of a max (or the opposite),
depending on the argument order of evaluation phiprop might do
the transformation or it might not (see tree-ssa/phiprop-3.C for examples).
So we need to allow skipping of one store inbetween the load and
where the phi is located.

Aggregates include a store when doing phiprop so we need to check
if there are also loads between the original store/load and the
store we are skipping. This can be added afterwards but I didn't
see aggregate case happening enough to make a big dent. I added
testcases (phiprop-{10,11}.c) to make sure cases where the load
would make a different shows up though.

changes since v1:
* v2: rewrite can_handle_load to avoid duplicated skipping store code.

	PR tree-optimization/123120
	PR tree-optimization/116823
gcc/ChangeLog:

	* tree-ssa-phiprop.cc (phiprop_insert_phi): Add other_vuse
	argument, use it instead of the vuse on the use_stmt.
	(can_handle_load): Add aggregate argument. Also return the vuse
	of the load/store when the insert is allowed.
	Skipping over one non-modifying store for !aggregate.
	(propagate_with_phi): Update call to can_handle_load
	and phiprop_insert_phi.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/phiprop-8.c: New test.
	* gcc.dg/tree-ssa/phiprop-9.c: New test.
	* gcc.dg/tree-ssa/phiprop-10.c: New test.
	* gcc.dg/tree-ssa/phiprop-11.c: New test.
	* gcc.dg/tree-ssa/phiprop-12.c: New test.
	* g++.dg/tree-ssa/phiprop-3.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2026-05-04 06:48:59 -07:00
2026-05-01 00:16:27 +00:00
2026-04-29 00:16:40 +00:00
2026-04-30 00:16:31 +00:00
2026-05-03 00:16:23 +00:00
2026-05-02 00:16:28 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%