This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Feb 2012 13:27:23 +0000
- Subject: [Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function.
- Auto-submitted: auto-generated
- References: <bug-52326-4@http.gcc.gnu.org/bugzilla/>
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 ();
}