http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-21 
13:27:23 UTC ---
Reduced single-file testcase, fails at -O1:

float fabsf(float x);
void abort (void);

static float minf(float a, float b)
{
  return (a < b) ? a: b;
}

static float maxf(float a, float b)
{
  return (a > b) ? a: b;
}

struct EC {
    float fftout;
    int extragainOn;
};

static float __attribute__((noinline))
foo (float a)
{
  asm("");
  return a;
}

static struct EC * __attribute__((noinline))
ec_create(void)
{
  static struct EC p;

  p.fftout = 1.234567f;
  p.extragainOn = 1;
  return &p;
}

static float ec_process(struct EC *p, float beflev, float estlev)
{
  float fullgCorr;
  float extrag;

  fullgCorr = maxf(0.0f, beflev - estlev) / beflev;
  extrag = 1.0f;

  if (p->extragainOn)
    extrag = minf(1.0f, fullgCorr);

  foo(0.0f);
  return extrag * p->fftout;
}

int main(void)
{
  unsigned int i = 0;
  float beflev[] = {11.6f, 1.0f};
  float estlev[] = {11.5f, 1.0f};
  float output;
  struct EC *p = ec_create();

  /* NOTE: If the for-loop is removed, the error disappears */
  for (i = 0; i < 1; i++)
    output = ec_process(p, beflev[i], estlev[i]);

  if (fabsf(output - 0.010643f) < 1e-5f)
    return 0;
  else
    abort ();
}

Reply via email to