]> git.ipfire.org Git - thirdparty/gcc.git/commit
ifcombine: avoid unsound forwarder-enabled combinations [PR117723]
authorAlexandre Oliva <oliva@adacore.com>
Fri, 29 Nov 2024 08:42:28 +0000 (05:42 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 29 Nov 2024 08:42:28 +0000 (05:42 -0300)
commit70f7c603da67adff13e41831ab8ec4e2f6fadc2c
tree8da57145b840b98ba515917ddc98b52483a42b2e
parent52e56eef53b444b5b86c3492e5a7a079c010c1c9
ifcombine: avoid unsound forwarder-enabled combinations [PR117723]

When ifcombining contiguous blocks, we can follow forwarder blocks and
reverse conditions to enable combinations, but when there are
intervening blocks, we have to constrain ourselves to paths to the
exit that share the PHI args with all intervening blocks.

Avoiding considering forwarders when intervening blocks were present
would match the preexisting test, but we can do better, recording in
case a forwarded path corresponds to the outer block's exit path, and
insisting on not combining through any other path but the one that was
verified as corresponding.  The latter is what this patch implements.

While at that, I've fixed some typos, introduced early testing before
computing the exit path to avoid it when computing it would be
wasteful, or when avoiding it can enable other sound combinations.

for  gcc/ChangeLog

PR tree-optimization/117723
* tree-ssa-ifcombine.cc (tree_ssa_ifcombine_bb): Record
forwarder blocks in path to exit, and stick to them.  Avoid
computing the exit if obviously not needed, and if that
enables additional optimizations.
(tree_ssa_ifcombine_bb_1): Fix typos.

for  gcc/testsuite/ChangeLog

PR tree-optimization/117723
* gcc.dg/torture/ifcmb-1.c: New.
gcc/testsuite/gcc.dg/torture/ifcmb-1.c [new file with mode: 0644]
gcc/tree-ssa-ifcombine.cc