https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116817
--- Comment #6 from GCC 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:87905f63a6521eef1f38082e2368e18c637ef092 commit r15-3959-g87905f63a6521eef1f38082e2368e18c637ef092 Author: Tamar Christina <tamar.christ...@arm.com> Date: Mon Sep 30 13:06:24 2024 +0100 middle-end: check explicitly for external or constants when checking for loop invariant [PR116817] The previous check if a value was external was checking !vect_get_internal_def (vinfo, var) but this of course isn't completely right as they could reductions etc. This changes the check to just explicitly look at externals and constants. Note that reductions remain unhandled here, but we don't support codegen of boolean reductions today anyway. So at the time we do then this would have the be handled as well in lowering. gcc/ChangeLog: PR tree-optimization/116817 * tree-vect-patterns.cc (vect_recog_bool_pattern): Check for const or externals. gcc/testsuite/ChangeLog: PR tree-optimization/116817 * g++.dg/vect/pr116817.cc: New test.