https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110838
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:1a599caab86464006ea8c9501aff6c6638e891eb commit r14-2987-g1a599caab86464006ea8c9501aff6c6638e891eb Author: Richard Biener <rguent...@suse.de> Date: Fri Aug 4 12:11:45 2023 +0200 tree-optimization/110838 - vectorization of widened right shifts The following fixes a problem with my last attempt of avoiding out-of-bound shift values for vectorized right shifts of widened operands. Instead of truncating the shift amount with a bitwise and we actually need to saturate it to the target precision. The following does that and adds test coverage for the constant and invariant but variable case that would previously have failed. PR tree-optimization/110838 * tree-vect-patterns.cc (vect_recog_over_widening_pattern): Fix right-shift value sanitizing. Properly emit external def mangling in the preheader rather than in the pattern def sequence where it will fail vectorizing. * gcc.dg/vect/pr110838.c: New testcase.