https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110381
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Lennox Ho from comment #3) > Thanks. -fno-tree-vectorize appears to fix GCC 12.1 at -O2. > > Curious, why is -ftree-vectorize enabled at -O2 with GCC 12.1? Yes see https://gcc.gnu.org/gcc-12/changes.html#general . > The documents say it's only turned on by default with -O3 > ``` > https://gcc.gnu.org/projects/tree-ssa/vectorization.html > Vectorization is enabled by the flag -ftree-vectorize and by default at -O3 > ``` That is not the documentation for the release but rather for the project while it was during development of it originally (back in early 2000s). The documentation for the GCC 12.1 release is located at: https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gcc/Optimize-Options.html#index-ftree-vectorize Which specifically mentions -ftree-loop-vectorize and -ftree-slp-vectorize are enabled at -O2 and above (-ftree-vectorize is a meta option for those 2 options).