https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113287
--- 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:91fd5c94965b4077490c6bfcc9aa4b0e4146b38a commit r14-7109-g91fd5c94965b4077490c6bfcc9aa4b0e4146b38a Author: Tamar Christina <tamar.christ...@arm.com> Date: Wed Jan 10 14:31:02 2024 +0000 middle-end: correctly identify the edge taken when condition is true. [PR113287] The vectorizer needs to know during early break vectorization whether the edge that will be taken if the condition is true stays or leaves the loop. This is because the code assumes that if you take the true branch you exit the loop. If you don't exit the loop it has to generate a different condition. Basically it uses this information to decide whether it's generating a "any element" or an "all element" check. Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu and no issues with --enable-lto --with-build-config=bootstrap-O3 --enable-checking=release,yes,rtl,extra. gcc/ChangeLog: PR tree-optimization/113287 * tree-vect-stmts.cc (vectorizable_early_exit): Check the flags on edge instead of using BRANCH_EDGE to determine true edge. gcc/testsuite/ChangeLog: PR tree-optimization/113287 * gcc.dg/vect/vect-early-break_100-pr113287.c: New test. * gcc.dg/vect/vect-early-break_99-pr113287.c: New test.