]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/118817 - missed folding of PRE inserted code
authorRichard Biener <rguenther@suse.de>
Tue, 11 Feb 2025 09:29:18 +0000 (10:29 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 11 Feb 2025 11:42:04 +0000 (12:42 +0100)
commit0a1d2ea57722c248777e1130de076e28c443ff8b
tree45cfc6d6a626375014681b95b1a464327fb29605
parent1bfab1dc79bef1f1120bda37556f2e372a2378f5
tree-optimization/118817 - missed folding of PRE inserted code

When PRE inserts code it is not fully folded with following SSA
edges which can cause missed optimizations since the next fully
folding pass is way ahead, after strlen which in the PRs case leads
to diagnostics emitted on dead code.

The following mitigates the missed expression canonicalization that
happens during PHI translation where to be inserted expressions are
calculated.  It is largely refactoring and eliminating the single
use of fully_constant_expression and otherwise leverages the
work already done by vn_nary_simplify by updating the NARY with
the simplified expression.

PR tree-optimization/118817
* tree-ssa-pre.cc (fully_constant_expression): Fold into
the single caller.
(phi_translate_1): Refactor folded in fully_constant_expression.
* tree-ssa-sccvn.cc (vn_nary_simplify): Update the NARY with
the simplified expression.

* g++.dg/lto/pr118817_0.C: New testcase.
gcc/testsuite/g++.dg/lto/pr118817_0.C [new file with mode: 0644]
gcc/tree-ssa-pre.cc
gcc/tree-ssa-sccvn.cc