https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111860
--- Comment #23 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <tnfch...@gcc.gnu.org>: https://gcc.gnu.org/g:9ed6b22eb4188c57bb3f5cdba5a7effa95395186 commit r14-4861-g9ed6b22eb4188c57bb3f5cdba5a7effa95395186 Author: Tamar Christina <tamar.christ...@arm.com> Date: Mon Oct 23 14:07:20 2023 +0100 middle-end: don't keep .MEM guard nodes for PHI nodes who dominate loop [PR111860] The previous patch tried to remove PHI nodes that dominated the first loop, however the correct fix is to only remove .MEM nodes. This patch thus makes the condition a bit stricter and only tries to remove MEM phi nodes. I couldn't figure out a way to easily determine if a particular PHI is vUSE related, so the patch does: 1. check if the definition is a vDEF and not defined in main loop. 2. check if the definition is a PHI and not defined in main loop. 3. check if the definition is a default definition. For no 2 and 3 we may misidentify the PHI, in both cases the value is defined outside of the loop version block which also makes it ok to remove. gcc/ChangeLog: PR tree-optimization/111860 * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg): Drop .MEM nodes only. gcc/testsuite/ChangeLog: PR tree-optimization/111860 * gcc.dg/vect/pr111860-2.c: New test. * gcc.dg/vect/pr111860-3.c: New test.