]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/117965 - phiprop validity checking is too strict
authorRichard Biener <rguenther@suse.de>
Tue, 10 Dec 2024 08:55:37 +0000 (09:55 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 27 May 2025 13:19:08 +0000 (15:19 +0200)
commit8da568c885dc90ac5c7d9aee34ae78d5cfb8918c
tree6e9c712c8fae2085d46aedc5e593344564f1f97f
parentec5349c37afe972ee79b777ee749630b1a0a007e
tree-optimization/117965 - phiprop validity checking is too strict

The PR shows that when using std::clamp from the C++ standard library
and there is surrounding code using exceptions then phiprop can fail
to simplify the code so phiopt can turn the clamping into efficient
min/max operations.

The validation code is needlessly complicated, steming from the
time we had memory-SSA with multiple virtual operands.  The following
simplifies this, thereby fixing this issue.

PR tree-optimization/117965
* tree-ssa-phiprop.cc (phivn_valid_p): Remove.
(propagate_with_phi): Pass in virtual PHI node from BB,
rewrite load motion validity check to require the same
virtual use along all paths.

* g++.dg/tree-ssa/pr117965-1.C: New testcase.
* g++.dg/tree-ssa/pr117965-2.C: Likewise.
gcc/testsuite/g++.dg/tree-ssa/pr117965-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/pr117965-2.C [new file with mode: 0644]
gcc/tree-ssa-phiprop.cc