diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-04-07 11:57:36 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-04-07 11:57:36 +0200 |
commit | e7c3a7ccd6209c1a906bdf59207f0fa4258b692b (patch) | |
tree | dd1e9746570ea2ff6b3690461caa987ace058b68 /libjava/javax/swing/Spring$3.h | |
parent | 1534f0099c98ea14c08a401302b05edf2231f411 (diff) | |
download | gcc-e7c3a7ccd6209c1a906bdf59207f0fa4258b692b.zip gcc-e7c3a7ccd6209c1a906bdf59207f0fa4258b692b.tar.gz gcc-e7c3a7ccd6209c1a906bdf59207f0fa4258b692b.tar.bz2 |
tailc: Extend the IPA-VRP workaround [PR119614]
The IPA-VRP workaround in the tailc/musttail passes was just comparing
the singleton constant from a tail call candidate return with the ret_val.
This unfortunately doesn't work in the following testcase, where we have
<bb 5> [local count: 152205050]:
baz (); [must tail call]
goto <bb 4>; [100.00%]
<bb 6> [local count: 762356696]:
_8 = foo ();
<bb 7> [local count: 1073741824]:
# _3 = PHI <0B(4), _8(6)>
return _3;
and in the unreduced testcase even more PHIs before we reach the return
stmt.
Normally when the call has lhs, whenever we follow a (non-EH) successor
edge, it calls propagate_through_phis and that walks the PHIs in the
destination bb of the edge and when it sees a PHI whose argument matches
that of the currently tracked value (ass_var), it updates ass_var to
PHI result of that PHI. I think it is theoretically dangerous that it
picks the first one, perhaps there could be multiple PHIs, so perhaps safer
would be walk backwards from the return value up to the call.
Anyway, this PR is about the IPA-VRP workaround, there ass_var is NULL
because the potential tail call has no lhs, but ret_var is not TREE_CONSTANT
but SSA_NAME with PHI as SSA_NAME_DEF_STMT. The following patch handles
it by pushing the edges we've walked through when ass_var is NULL into a
vector and if ret_var is SSA_NAME set to PHI result, it attempts to walk
back from the ret_var through arguments of PHIs corresponding to the
edges we've walked back until we reach a constant and compare that constant
against the singleton value as well.
2025-04-07 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/119614
* tree-tailcall.cc (find_tail_calls): Remember edges which have been
walked through if !ass_var. Perform IPA-VRP workaround even when
ret_var is not TREE_CONSTANT, in that case check in a loop if it is
a PHI result and in that case look at the PHI argument from
corresponding edge in the edge vector.
* g++.dg/opt/pr119613.C: Change { c || c++11 } in obviously C++ only
test to just c++11.
* g++.dg/opt/pr119614.C: New test.
Diffstat (limited to 'libjava/javax/swing/Spring$3.h')
0 files changed, 0 insertions, 0 deletions