make an intermediate float variable "volatile" on i386 to work around a gcc
optimization problem: subsequent add/subs were done inside FPU registers, with "double" precision, without rounding to "float" in between
This commit is contained in:
parent
b6116cb922
commit
d81b3ce220
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lrintf.c,v 1.3 2004/10/13 15:18:32 drochner Exp $ */
|
||||
/* $NetBSD: lrintf.c,v 1.4 2006/08/01 20:14:35 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004
|
||||
@ -52,6 +52,10 @@ LRINTNAME(float x)
|
||||
u_int32_t i0;
|
||||
int e, s, shift;
|
||||
RESTYPE res;
|
||||
#ifdef __i386__ /* XXX gcc4 will omit the rounding otherwise */
|
||||
volatile
|
||||
#endif
|
||||
float w;
|
||||
|
||||
GET_FLOAT_WORD(i0, x);
|
||||
e = i0 >> SNG_FRACBITS;
|
||||
@ -68,8 +72,8 @@ LRINTNAME(float x)
|
||||
/* >= 2^23 is already an exact integer */
|
||||
if (e < SNG_FRACBITS) {
|
||||
/* round, using current direction */
|
||||
x += TWO23[s];
|
||||
x -= TWO23[s];
|
||||
w = TWO23[s] + x;
|
||||
x = w - TWO23[s];
|
||||
}
|
||||
|
||||
GET_FLOAT_WORD(i0, x);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBM_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: s_rintf.c,v 1.7 2002/05/26 22:01:58 wiz Exp $");
|
||||
__RCSID("$NetBSD: s_rintf.c,v 1.8 2006/08/01 20:14:35 drochner Exp $");
|
||||
#endif
|
||||
|
||||
#include "math.h"
|
||||
@ -32,7 +32,11 @@ rintf(float x)
|
||||
{
|
||||
int32_t i0,j0,sx;
|
||||
u_int32_t i,i1;
|
||||
float w,t;
|
||||
#ifdef __i386__ /* XXX gcc4 will omit the rounding otherwise */
|
||||
volatile
|
||||
#endif
|
||||
float w;
|
||||
float t;
|
||||
GET_FLOAT_WORD(i0,x);
|
||||
sx = (i0>>31)&1;
|
||||
j0 = ((i0>>23)&0xff)-0x7f;
|
||||
|
Loading…
Reference in New Issue
Block a user