This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented)
- From: "merkert at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2008 15:38:57 -0000
- Subject: [Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented)
- References: <bug-34678-5307@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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