This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented)



------- Comment #2 from merkert at comcast dot net  2008-01-05 15:38 -------
Ok, so how then would one accomplish this in std c without resorting to asm? I
still assume the original code is correct even though the rounding-math doesn't
do what I wanted.

At any rate, I played a little with it and there was hint in the asm manual how
to do it. This seems to work for me, but I'm not sure I'm using the constraints
as efficiently as possible:

#include <fenv.h>

inline void reload(double* x)
{
  asm volatile ("" : "=m"(x) );
}

void xdiv (double x, double y, double* lo, double* hi)
{
  #pragma STDC FENV_ACCESS ON
  fesetround(FE_DOWNWARD);
  *lo = x/y;

  reload(&y);

  fesetround(FE_UPWARD);
  *hi = x/y;
}


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]