]> git.ipfire.org Git - thirdparty/gcc.git/commit
backprop: Fix deleting of a phi node [PR116922]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 1 Oct 2024 21:48:19 +0000 (14:48 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 16 Apr 2025 21:25:41 +0000 (14:25 -0700)
commita5929ef809558a3117e7a6e2e66316a828b50f29
tree9b74b92d2b895b2f98ee905e61e6f0fd4afa1912
parent5347b382a38d664216bd7484dd5438a1863d02a3
backprop: Fix deleting of a phi node [PR116922]

The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116922

gcc/ChangeLog:

* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
nodes correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit cea87c84eacdb422caeada734ba5138c994d7022)
gcc/gimple-ssa-backprop.cc
gcc/testsuite/gcc.dg/torture/pr116922.c [new file with mode: 0644]