Subject: Re: gcc4 misoptimization
To: None <M.Drochner@fz-juelich.de>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-toolchain
Date: 07/27/2006 21:12:51
This is a multipart MIME message.

--==_Exmh_57313956893700
Content-Type: text/plain; charset=us-ascii


M.Drochner@fz-juelich.de said:
> the appended patch

Here is it...



--==_Exmh_57313956893700
Content-Type: text/plain ; name="lrintf.txt"; charset=us-ascii
Content-Description: lrintf.txt
Content-Disposition: attachment; filename="lrintf.txt"

Index: lrintf.c
===================================================================
RCS file: /cvsroot/src/lib/libm/src/lrintf.c,v
retrieving revision 1.3
diff -u -r1.3 lrintf.c
--- lrintf.c	13 Oct 2004 15:18:32 -0000	1.3
+++ lrintf.c	27 Jul 2006 18:39:08 -0000
@@ -68,8 +68,13 @@
 	/* >= 2^23 is already an exact integer */
 	if (e < SNG_FRACBITS) {
 		/* round, using current direction */
-		x += TWO23[s];
-		x -= TWO23[s];
+		{
+			/* XXX hack to avoid misoptimization */
+			volatile float xx = x;
+			xx += TWO23[s];
+			xx -= TWO23[s];
+			x = xx;
+		}
 	}
 
 	GET_FLOAT_WORD(i0, x);

--==_Exmh_57313956893700--