https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116922
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:cea87c84eacdb422caeada734ba5138c994d7022 commit r15-4008-gcea87c84eacdb422caeada734ba5138c994d7022 Author: Andrew Pinski <quic_apin...@quicinc.com> Date: Tue Oct 1 14:48:19 2024 -0700 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_apin...@quicinc.com>