This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

soft-fp truncation bug fix


This patch fixes a bug in soft-fp's truncation that showed up with the GCC 
test gcc.c-torture/execute/ieee/20000320-1.c:

* An off-by-one error meant values between half the smallest denormal and 
the smallest denormal got truncated to 0.

* Even for smaller exponents, the truncation needs to set the sticky bit 
for the sake of rounding modes where the result should be the smallest 
denormal not 0.

2007-04-30  Joseph Myers  <joseph@codesourcery.com>

	* soft-fp/op-common.h (FP_TRUNC): Correct off-by-one error in
	condition for truncating to 0.  Set sticky bit for such
	truncation.

Index: soft-fp/op-common.h
===================================================================
RCS file: /cvs/glibc/libc/soft-fp/op-common.h,v
retrieving revision 1.10
diff -u -r1.10 op-common.h
--- soft-fp/op-common.h	15 Jan 2007 23:43:04 -0000	1.10
+++ soft-fp/op-common.h	30 Apr 2007 22:22:09 -0000
@@ -1211,8 +1211,11 @@
 	{								     \
 	  if (D##_e <= 0)						     \
 	    {								     \
-	      if (D##_e <= 1 - _FP_FRACBITS_##dfs)			     \
-		_FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc);		     \
+	      if (D##_e < 1 - _FP_FRACBITS_##dfs)			     \
+		{							     \
+		  _FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc);		     \
+		  _FP_FRAC_LOW_##swc(S) |= 1;				     \
+		}							     \
 	      else							     \
 		{							     \
 		  _FP_FRAC_HIGH_##sfs(S) |= _FP_IMPLBIT_SH_##sfs;	     \

-- 
Joseph S. Myers
joseph@codesourcery.com


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