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

            Bug ID: 124180
           Summary: [16 Regression] No longer vectorized due to missed
                    if-conversion
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

The following is no longer vectorized on x86_64 at -O3 due to ifcvt:

_34 = (short unsigned int) v_33;
tree could trap...

as we cannot predicate a float to int conversion at the moment.


#define CLAMP(a, min, max) \
  ((a)>(max) ? (max) : ((min)>(a) ? (min) : (a)))

typedef unsigned short OUT_T;
static OUT_T CastValue (float value)
{
  const float v = value + 0.5f;
  return (OUT_T)CLAMP(v, 0.0f, 6.5535e+4);
}

typedef float IN_T;
const float m_scale = 3.;

void apply(const void * inImg, void * outImg, long numPixels)
{
  const IN_T * in = reinterpret_cast<const IN_T*>(inImg);
  OUT_T * out = reinterpret_cast<OUT_T *>(outImg);

  for(long pxl=0; pxl<numPixels; ++pxl)
    {
      out[0] = CastValue(in[0] * m_scale);
      out[1] = CastValue(in[1] * m_scale);
      out[2] = CastValue(in[2] * m_scale);
      out[3] = CastValue(in[3] * m_scale);

      in  += 4;
      out += 4;
    }
}

Reply via email to