https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124068
--- Comment #2 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:cdc4d4ada2e09f307c0bce6394352079088186a1 commit r16-7601-gcdc4d4ada2e09f307c0bce6394352079088186a1 Author: Richard Biener <[email protected]> Date: Wed Feb 18 13:46:38 2026 +0100 tree-optimization/124068 - fix missed AVX2 vectorization of shift The following fixes a regression in AVX2 vectorization because on trunk we are now correctly determine we can shorten a shift operation but we never really bothered to check we can implement the resulting operation. With the patch we now check this. For shifts and rotates we have the choice between vector-vector and vector-scalar operations which in the end depends on whether we perform SLP or not and how the shift operand matches up. The patch heuristically assumes that constant or external shifts can be handled by vector-scalar operations. As we were not checking for target support was to allow recursive matching other patterns, the following still errors on that side in case the original operation was not supported by the target or it is binary and the 2nd operand is a constant. This helps avoiding regressions in gcc.dg/vect/vect-over-widen-13.c and gcc.dg/vect/vect-div-bitmask-1.c and gcc.target/aarch64/sve2/div-by-bitmask_1.c where the operation in question is integer division. PR tree-optimization/124068 * tree-vect-patterns.cc (target_has_vecop_for_code): Move earlier, add defaulted optab_subtype parameter. (vect_recog_over_widening_pattern): Check that the target supports the narrowed operation before committing to the pattern. * gcc.target/i386/vect-shift-1.c: New testcase.
