tree-optimization/110838 - vectorization of widened right shifts
commit1a599caab86464006ea8c9501aff6c6638e891eb
authorRichard Biener <rguenther@suse.de>
Fri, 4 Aug 2023 10:11:45 +0000 (4 12:11 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 4 Aug 2023 11:15:05 +0000 (4 13:15 +0200)
treeff972a0135fd19369a611d67639fe1ad521a8b3a
parent0782b01c9ea43d43648071faa9c65a101f5068a2
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.
gcc/testsuite/gcc.dg/vect/pr110838.c [new file with mode: 0644]
gcc/tree-vect-patterns.cc