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

            Bug ID: 124176
           Summary: EVRP leaves around SSA copies
           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: ---

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

typedef float 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 unsigned short 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;
    }
}

with -O3 EVRP does

   <bb 4> :
-  _58 = v_57 < 0.0;
-  _59 = _58 ? 0.0 : v_57;
+  _59 = v_57;

leaving around the SSA copy _59 = v_57, eventually confusing phiopt which
fails to recognize

  if (v_49 > 6.5535e+4)
    goto <bb 9>; [50.00%]
  else
    goto <bb 8>; [50.00%]

  <bb 8> :
  _51 = v_49;

  <bb 9> :
  # _52 = PHI <6.5535e+4(7), _51(8)>

Reply via email to