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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Vincent Lefèvre from comment #5)
> (In reply to Andrew Pinski from comment #4)
> > A regression since GCC 3.2 (r0-47863-g881b2a9652748ad).
> 
> Always reproducible with GCC 5. But with GCC 4.7 to 4.9, it seems that one
> needs -O1 to get fldpi generated. I can't reproduce the bug with GCC 4.1.2
> to 4.6.4 on godbolt (even with -O3).

Here is a testcase which shows it can be reproduced all the back to GCC 4.1.2
even:

#include <fenv.h>

#define X 0xc.90fdaa22168c235p-2l
#define Y 0xc.90fdaa22168c234p-2l
__attribute__((noinline))
void g(long double x){}
__attribute((noinline))
int f(long double z)
{
  volatile long double x, y;

  fesetround (FE_TOWARDZERO);
  x = X + z;
  g(x);
  y = Y + z;
  return x - y == ((X) - (Y)) ? 0 : 1;
}


int main (void)
{
    f(0);
}

Reply via email to