]> git.ipfire.org Git - thirdparty/gcc.git/commit
ifcvt: Fix ifcvt for multiple phi nodes after factoring operator [PR121236]
authorAndrew Pinski <quic_apinski@quicinc.com>
Fri, 25 Jul 2025 20:54:32 +0000 (13:54 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 28 Jul 2025 17:24:51 +0000 (10:24 -0700)
commita51bf9e10182cf7ac858db0ea6c5cb11b4f12377
treee171c442f9fbbbe723044b357f82afd6ea25cdac
parent5760ddbce26ff9c5c8851b6b2089ad65981d5078
ifcvt: Fix ifcvt for multiple phi nodes after factoring operator [PR121236]

When I added the factor operations to ifcvt, I messed how handling of removing
the phi nodes. The fix is we need to remove the phi node that was factored out
as we factored out the operator because otherwise scev can go when it comes
to detecting if the new args are from a reduction.

Also the need to change the interface for is_cond_scalar_reduction as the
phi node that was being passed after the factoring no longer exists so need
to pass the parts that were being used.

PR tree-optimization/121236

gcc/ChangeLog:

* tree-if-conv.cc (is_cond_scalar_reduction): Instead of phi argument,
pass bb and res of the phi.
(factor_out_operators): Add iterator for the phi. Remove the phi
if this is the first time. Return if we had removed the phi.
(predicate_scalar_phi): Add the phi iterator argument.
Update call to is_cond_scalar_reduction.
Update call to factor_out_operators and set the return value to true
when factor_out_operators returns true.
(predicate_all_scalar_phis): Don't remove the phi if predicate_scalar_phi
already removed it.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr121236-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/gcc.dg/torture/pr121236-1.c [new file with mode: 0644]
gcc/tree-if-conv.cc