https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103771

            Bug ID: 103771
           Summary: Missed vectorization under -mavx512f -mavx512vl after
                    r12-5489
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wwwhhhyyy333 at gmail dot com
  Target Milestone: ---

cat vect.c

typedef unsigned char uint8_t;                                                  

static uint8_t x264_clip_uint8( int x )                                         
{                                                                               
    return x&(~255) ? (-x)>>31 : x;                                             
}                                                                               

void mc_weight( uint8_t * __restrict dst, uint8_t * __restrict src, int
i_width, int i_scale)
{                                                                               
  for( int x = 0; x < i_width; x++ )                                            
    dst[x] = x264_clip_uint8(src[x] * i_scale);                                 
}                                                                               

It can not be vectorized with -mavx512f -mavx512vl, but can be vectorized with
-mavx2, See https://godbolt.org/z/M1jx161f6

The commit https://gcc.gnu.org/cgi-bin/gcc-gitref.cgi?r=r12-5489 converts  (x &
(~255)) == 0 to x <= 255, which may trigger some missing pattern with
-mavx512vl. 

Also an 1.5% regression was found on -march=cascadelake due to missing 128bit
epilogue for this loop.

Reply via email to