Go to file
Richard Biener e25dce5013 tree-optimization/103037 - PRE simplifying valueized expressions
This fixes a long-standing issue in PRE where we track valueized
expressions in our expression sets that we use for PHI translation,
code insertion but also feed into match-and-simplify via
vn_nary_simplify.  But that's not what is expected from vn_nary_simplify
or match-and-simplify which assume we are simplifying with operands
available at the point of the expression so they can use contextual
information on the SSA names like ranges.  While the VN side was
updated to ensure this with the rewrite to RPO VN, thereby removing
all workarounds that nullified such contextual info on all SSA names,
the PRE side still suffers from this.

The following patch tries to apply minimal surgery at this point
and makes PRE track un-valueized expressions in the expression sets
but only for the NARY kind (both NAME and CONSTANT do not suffer
from this issue), leaving the REFERENCE kind alone.  The REFERENCE
kind is important when trying to remove the workarounds still in
place in compute_avail for code hoisting, but that's a separate issue
and we have a working workaround in place.

Doing this comes at the cost of duplicating the VN IL on the PRE side
for NARY and eventually some extra overhead for translated expressions
that is difficult to assess.

2022-02-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/103037
	* tree-ssa-sccvn.h (alloc_vn_nary_op_noinit): Declare.
	(vn_nary_length_from_stmt): Likewise.
	(init_vn_nary_op_from_stmt): Likewise.
	(vn_nary_op_compute_hash): Likewise.
	* tree-ssa-sccvn.cc (alloc_vn_nary_op_noinit): Export.
	(vn_nary_length_from_stmt): Likewise.
	(init_vn_nary_op_from_stmt): Likewise.
	(vn_nary_op_compute_hash): Likewise.
	* tree-ssa-pre.cc (pre_expr_obstack): New obstack.
	(get_or_alloc_expr_for_nary): Pass in the value-id to use,
	(re-)compute the hash value and if the expression is not
	found allocate it from pre_expr_obstack.
	(phi_translate_1): Do not insert the NARY found in the
	VN tables but build a PRE expression from the valueized
	NARY with the value-id we eventually found.
	(find_or_generate_expression): Assert we have an entry
	for constant values.
	(compute_avail): Insert not valueized expressions into
	EXP_GEN using the value-id from the VN tables.
	(init_pre): Allocate pre_expr_obstack.
	(fini_pre): Free pre_expr_obstack.

	* gcc.dg/torture/pr103037.c: New testcase.
2022-02-25 13:20:40 +01:00
c++tools
config
contrib
fixincludes
gcc tree-optimization/103037 - PRE simplifying valueized expressions 2022-02-25 13:20:40 +01:00
gnattools
gotools Daily bump. 2022-02-14 00:16:23 +00:00
include
INSTALL
intl
libada
libatomic
libbacktrace Daily bump. 2022-02-18 00:16:39 +00:00
libcc1
libcody
libcpp Daily bump. 2022-02-12 00:16:23 +00:00
libdecnumber
libffi
libgcc Daily bump. 2022-02-25 00:16:20 +00:00
libgfortran
libgo libgo: update README.gcc 2022-02-22 15:34:46 -08:00
libgomp Daily bump. 2022-02-25 00:16:20 +00:00
libiberty Daily bump. 2022-02-23 00:16:24 +00:00
libitm
libobjc
liboffloadmic
libphobos Daily bump. 2022-02-21 00:16:24 +00:00
libquadmath
libsanitizer Daily bump. 2022-02-16 00:16:26 +00:00
libssp
libstdc++-v3 Daily bump. 2022-02-25 00:16:20 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2022-02-23 00:16:24 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Update my email address. 2022-02-22 15:55:05 +00:00
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

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.