https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127814
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:9b4df7d052915431725e58156754dfb077b915c1 commit r17-5080-g9b4df7d052915431725e58156754dfb077b915c1 Author: Richard Biener <[email protected]> Date: Mon Oct 12 09:17:01 2026 +0200 tree-optimization/127814 - niter assumptions / may_be_zero and UB The following avoids UB and following miscompiles via ranger when vectorizing loops that have niter assumptions and/or may_be_zero conditions. We end up emitting those in non-short-circuited form during versioning and the least intrusive change, suitable for backporting, seems to be to make sure to emit the assumptions first and rewrite them to defined operations. The optimization to put those into a separate block, short-circuiting other versioning conditions should shield those. There is existing attempts at mitigating issues with regard to the may_be_zero condition, but that's guarding only against -ftrapv, so there's still a hole for that case. PR tree-optimization/127814 * tree-vect-loop-manip.cc (vect_loop_versioning): Emit versioning for niter assumption conditions first and split those to the separate BB together with the cost model check after rewriting all of it to unconditional defined operations. * gcc.dg/vect/vect-pr127814.c: New testcase.
