about summary refs log tree commit diff
path: root/soft-fp/op-common.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-05-03 16:36:49 +0000
committerJakub Jelinek <jakub@redhat.com>2007-05-03 16:36:49 +0000
commit37002cbcd2ef5cabca946a877700855c0dd69028 (patch)
treeff0394bff7f1a85b22986ede3bd7860e114a712a /soft-fp/op-common.h
parent002f0b0b5df92cc1c1302c6b95c0c97fd986ed94 (diff)
downloadglibc-37002cbcd2ef5cabca946a877700855c0dd69028.tar.gz
glibc-37002cbcd2ef5cabca946a877700855c0dd69028.tar.xz
glibc-37002cbcd2ef5cabca946a877700855c0dd69028.zip
* soft-fp/op-common.h (FP_TRUNC): Replace raising of FP_EX_INEXACT cvs/fedora-glibc-20070504T0917
with setting the sticky bit. 
* math/test-misc.c (main): Add more truncation tests.
	* soft-fp/floatunsidf.c (__floatunsidf): Use DFtype instead of
	double in the function declaration.
	* soft-fp/floatundidf.c (__floatundidf): Use DFtype instead of
	double in the function declaration.
	* soft-fp/floatunsisf.c (__floatunsisf): Use SFtype instead of
	float in the function declaration.
	* soft-fp/floatunsisf.c (__floatunsisf): Use SFtype instead of
	float in the function declaration.

	* soft-fp/extended.h (FP_UNPACK_RAW_E): Do not increase X##_e for
	denormal operands.  Do not generate FP_EX_DENORM exception.
	(FP_UNPACK_RAW_EP): Ditto.
	(FP_UNPACK_SEMIRAW_E): Use FP_UNPACK_RAW_E instead of
	undefined _FP_UNPACK_RAW_E.
	(FP_UNPACK_SEMIRAW_EP): Use FP_UNPACK_RAW_EP instead of
	undefined _FP_UNPACK_RAW_EP.
	(FP_PACK_SEMIRAW_E): Use FP_PACK_RAW_E instead of
	undefined _FP_PACK_RAW_E.
	(FP_PACK_SEMIRAW_EP): Use FP_PACK_RAW_EP instead of
	undefined _FP_PACK_RAW_EP.

	* op-2.h (_FP_FRAC_COPY_2_2): Define as alias to _FP_FRAC_COPY_2.
	* op-4.h (_FP_FRAC_COPY_2_2): Define as alias to _FP_FRAC_COPY_4.

	* soft-fp/op-common.h (FP_EXTEND): Do not abort when
	_FP_EXPBIAS_##dfs == _FP_EXPBIAS_##sfs.  Handle denormals for
	this case.
	* soft-fp/op-common.h (FP_TRUNC): Ditto.
	* soft-fp/op-common.h (FP_TRUNC): Replace raising of FP_EX_INEXACT
	with setting the sticky bit.
	* math/test-misc.c (main): Add more truncation tests.

2007-04-14  Uros Bizjak  <ubizjak@gmail.com>

	* soft-fp/floatunsidf.c (__floatunsidf): Use DFtype instead of
	double in the function declaration.
	* soft-fp/floatundidf.c (__floatundidf): Use DFtype instead of
	double in the function declaration.
	* soft-fp/floatunsisf.c (__floatunsisf): Use SFtype instead of
	float in the function declaration.
	* soft-fp/floatunsisf.c (__floatunsisf): Use SFtype instead of
	float in the function declaration.

	* soft-fp/extended.h (FP_UNPACK_RAW_E): Do not increase X##_e for
	denormal operands.  Do not generate FP_EX_DENORM exception.
	(FP_UNPACK_RAW_EP): Ditto.
	(FP_UNPACK_SEMIRAW_E): Use FP_UNPACK_RAW_E instead of
	undefined _FP_UNPACK_RAW_E.
	(FP_UNPACK_SEMIRAW_EP): Use FP_UNPACK_RAW_EP instead of
	undefined _FP_UNPACK_RAW_EP.
	(FP_PACK_SEMIRAW_E): Use FP_PACK_RAW_E instead of
	undefined _FP_PACK_RAW_E.
	(FP_PACK_SEMIRAW_EP): Use FP_PACK_RAW_EP instead of
	undefined _FP_PACK_RAW_EP.

	* op-2.h (_FP_FRAC_COPY_2_2): Define as alias to _FP_FRAC_COPY_2.
	* op-4.h (_FP_FRAC_COPY_2_2): Define as alias to _FP_FRAC_COPY_4.

2007-04-16  Uros Bizjak  <ubizjak@gmail.com>
	    Jakub Jelinek  <jakub@redhat.com>

	* soft-fp/op-common.h (FP_EXTEND): Do not abort when
	_FP_EXPBIAS_##dfs == _FP_EXPBIAS_##sfs.  Handle denormals for
	this case.
	* soft-fp/op-common.h (FP_TRUNC): Ditto.

2007-05-03  Jakub Jelinek  <jakub@redhat.com>
Diffstat (limited to 'soft-fp/op-common.h')
-rw-r--r--soft-fp/op-common.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h
index 1f58b89478..ef11b527b7 100644
--- a/soft-fp/op-common.h
+++ b/soft-fp/op-common.h
@@ -1153,7 +1153,8 @@ do {									 \
   if (_FP_FRACBITS_##dfs < _FP_FRACBITS_##sfs				 \
       || (_FP_EXPMAX_##dfs - _FP_EXPBIAS_##dfs				 \
 	  < _FP_EXPMAX_##sfs - _FP_EXPBIAS_##sfs)			 \
-      || _FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1) \
+      || (_FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1 \
+	  && _FP_EXPBIAS_##dfs != _FP_EXPBIAS_##sfs))			 \
     abort();								 \
   D##_s = S##_s;							 \
   _FP_FRAC_COPY_##dwc##_##swc(D, S);					 \
@@ -1168,6 +1169,14 @@ do {									 \
 	{								 \
 	  if (_FP_FRAC_ZEROP_##swc(S))					 \
 	    D##_e = 0;							 \
+	  else if (_FP_EXPBIAS_##dfs					 \
+		   < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1)	 \
+	    {								 \
+	      FP_SET_EXCEPTION(FP_EX_DENORM);				 \
+	      _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs			 \
+				     - _FP_FRACBITS_##sfs));		 \
+	      D##_e = 0;						 \
+	    }								 \
 	  else								 \
 	    {								 \
 	      int _lz;							 \
@@ -1199,7 +1208,8 @@ do {									 \
 #define FP_TRUNC(dfs,sfs,dwc,swc,D,S)					     \
 do {									     \
   if (_FP_FRACBITS_##sfs < _FP_FRACBITS_##dfs				     \
-      || _FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1)     \
+      || (_FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1     \
+	  && _FP_EXPBIAS_##sfs != _FP_EXPBIAS_##dfs))			     \
     abort();								     \
   D##_s = S##_s;							     \
   if (_FP_EXP_NORMAL(sfs, swc, S))					     \
@@ -1237,11 +1247,24 @@ do {									     \
       if (S##_e == 0)							     \
 	{								     \
 	  D##_e = 0;							     \
-	  _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);			     \
-	  if (!_FP_FRAC_ZEROP_##swc(S))					     \
+	  if (_FP_FRAC_ZEROP_##swc(S))					     \
+	    _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);			     \
+	  else								     \
 	    {								     \
 	      FP_SET_EXCEPTION(FP_EX_DENORM);				     \
-	      FP_SET_EXCEPTION(FP_EX_INEXACT);				     \
+	      if (_FP_EXPBIAS_##sfs					     \
+		  < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1)		     \
+		{							     \
+		  _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs		     \
+					 - _FP_WFRACBITS_##dfs),	     \
+				     _FP_WFRACBITS_##sfs);		     \
+		  _FP_FRAC_COPY_##dwc##_##swc(D, S);			     \
+		}							     \
+	      else							     \
+		{							     \
+		  _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc);		     \
+		  _FP_FRAC_LOW_##dwc(D) |= 1;				     \
+		}							     \
 	    }								     \
 	}								     \
       else								     \