All of lore.kernel.org
 help / color / mirror / Atom feed
* math emulator patch
@ 2001-11-30  1:38 Mark Salter
  2001-11-30 23:36   ` Kjeld Borch Egevang
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Salter @ 2001-11-30  1:38 UTC (permalink / raw)
  To: linux-mips


The following patch fixes the emulation of cvt.w.s and cvt.w.d for
values of -2147483648.

--Mark


Index: sp_tint.c
===================================================================
RCS file: /cvs/linux/arch/mips/math-emu/sp_tint.c,v
retrieving revision 1.4
diff -u -p -5 -c -r1.4 sp_tint.c
cvs server: conflicting specifications of output style
*** sp_tint.c	2001/10/09 23:56:19	1.4
--- sp_tint.c	2001/11/29 19:14:58
*************** int ieee754sp_tint(ieee754sp x)
*** 48,57 ****
--- 48,60 ----
  	case IEEE754_CLASS_DNORM:
  	case IEEE754_CLASS_NORM:
  		break;
  	}
  	if (xe >= 31) {
+ 		/* look for valid corner case */
+ 		if (xe == 31 && xs && xm == SP_HIDDEN_BIT)
+ 			return -2147483648;
  		/* Set invalid. We will only use overflow for floating
  		   point overflow */
  		SETCX(IEEE754_INVALID_OPERATION);
  		return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
  	}
Index: dp_tint.c
===================================================================
RCS file: /cvs/linux/arch/mips/math-emu/dp_tint.c,v
retrieving revision 1.4
diff -u -p -5 -c -r1.4 dp_tint.c
cvs server: conflicting specifications of output style
*** dp_tint.c	2001/10/09 23:56:18	1.4
--- dp_tint.c	2001/11/29 19:18:02
*************** int ieee754dp_tint(ieee754dp x)
*** 48,57 ****
--- 48,60 ----
  	case IEEE754_CLASS_DNORM:
  	case IEEE754_CLASS_NORM:
  		break;
  	}
  	if (xe >= 31) {
+ 		/* look for valid corner case */
+ 		if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
+ 			return -2147483648;
  		/* Set invalid. We will only use overflow for floating
  		   point overflow */
  		SETCX(IEEE754_INVALID_OPERATION);
  		return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
  	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
@ 2001-11-30 23:36   ` Kjeld Borch Egevang
  0 siblings, 0 replies; 7+ messages in thread
From: Kjeld Borch Egevang @ 2001-11-30 23:36 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-mips

Great. The same problem exists for sp_tlong.c and dp_tlong.c.

/Kjeld

On Thu, 29 Nov 2001, Mark Salter wrote:

> 
> The following patch fixes the emulation of cvt.w.s and cvt.w.d for
> values of -2147483648.
> 
> --Mark
> 
> 
> Index: sp_tint.c
> ===================================================================
> RCS file: /cvs/linux/arch/mips/math-emu/sp_tint.c,v
> retrieving revision 1.4
> diff -u -p -5 -c -r1.4 sp_tint.c
> cvs server: conflicting specifications of output style
> *** sp_tint.c	2001/10/09 23:56:19	1.4
> --- sp_tint.c	2001/11/29 19:14:58
> *************** int ieee754sp_tint(ieee754sp x)
> *** 48,57 ****
> --- 48,60 ----
>   	case IEEE754_CLASS_DNORM:
>   	case IEEE754_CLASS_NORM:
>   		break;
>   	}
>   	if (xe >= 31) {
> + 		/* look for valid corner case */
> + 		if (xe == 31 && xs && xm == SP_HIDDEN_BIT)
> + 			return -2147483648;
>   		/* Set invalid. We will only use overflow for floating
>   		   point overflow */
>   		SETCX(IEEE754_INVALID_OPERATION);
>   		return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
>   	}
> Index: dp_tint.c
> ===================================================================
> RCS file: /cvs/linux/arch/mips/math-emu/dp_tint.c,v
> retrieving revision 1.4
> diff -u -p -5 -c -r1.4 dp_tint.c
> cvs server: conflicting specifications of output style
> *** dp_tint.c	2001/10/09 23:56:18	1.4
> --- dp_tint.c	2001/11/29 19:18:02
> *************** int ieee754dp_tint(ieee754dp x)
> *** 48,57 ****
> --- 48,60 ----
>   	case IEEE754_CLASS_DNORM:
>   	case IEEE754_CLASS_NORM:
>   		break;
>   	}
>   	if (xe >= 31) {
> + 		/* look for valid corner case */
> + 		if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
> + 			return -2147483648;
>   		/* Set invalid. We will only use overflow for floating
>   		   point overflow */
>   		SETCX(IEEE754_INVALID_OPERATION);
>   		return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
>   	}
> 

-- 
_    _ ____  ___                       Mailto:kjelde@mips.com
|\  /|||___)(___    MIPS Denmark       Direct: +45 44 86 55 85
| \/ |||    ____)   Lautrupvang 4 B    Switch: +45 44 86 55 55
  TECHNOLOGIES      DK-2750 Ballerup   Fax...: +45 44 86 55 56
                    Denmark            http://www.mips.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
@ 2001-11-30 23:36   ` Kjeld Borch Egevang
  0 siblings, 0 replies; 7+ messages in thread
From: Kjeld Borch Egevang @ 2001-11-30 23:36 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-mips

Great. The same problem exists for sp_tlong.c and dp_tlong.c.

/Kjeld

On Thu, 29 Nov 2001, Mark Salter wrote:

> 
> The following patch fixes the emulation of cvt.w.s and cvt.w.d for
> values of -2147483648.
> 
> --Mark
> 
> 
> Index: sp_tint.c
> ===================================================================
> RCS file: /cvs/linux/arch/mips/math-emu/sp_tint.c,v
> retrieving revision 1.4
> diff -u -p -5 -c -r1.4 sp_tint.c
> cvs server: conflicting specifications of output style
> *** sp_tint.c	2001/10/09 23:56:19	1.4
> --- sp_tint.c	2001/11/29 19:14:58
> *************** int ieee754sp_tint(ieee754sp x)
> *** 48,57 ****
> --- 48,60 ----
>   	case IEEE754_CLASS_DNORM:
>   	case IEEE754_CLASS_NORM:
>   		break;
>   	}
>   	if (xe >= 31) {
> + 		/* look for valid corner case */
> + 		if (xe == 31 && xs && xm == SP_HIDDEN_BIT)
> + 			return -2147483648;
>   		/* Set invalid. We will only use overflow for floating
>   		   point overflow */
>   		SETCX(IEEE754_INVALID_OPERATION);
>   		return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
>   	}
> Index: dp_tint.c
> ===================================================================
> RCS file: /cvs/linux/arch/mips/math-emu/dp_tint.c,v
> retrieving revision 1.4
> diff -u -p -5 -c -r1.4 dp_tint.c
> cvs server: conflicting specifications of output style
> *** dp_tint.c	2001/10/09 23:56:18	1.4
> --- dp_tint.c	2001/11/29 19:18:02
> *************** int ieee754dp_tint(ieee754dp x)
> *** 48,57 ****
> --- 48,60 ----
>   	case IEEE754_CLASS_DNORM:
>   	case IEEE754_CLASS_NORM:
>   		break;
>   	}
>   	if (xe >= 31) {
> + 		/* look for valid corner case */
> + 		if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
> + 			return -2147483648;
>   		/* Set invalid. We will only use overflow for floating
>   		   point overflow */
>   		SETCX(IEEE754_INVALID_OPERATION);
>   		return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
>   	}
> 

-- 
_    _ ____  ___                       Mailto:kjelde@mips.com
|\  /|||___)(___    MIPS Denmark       Direct: +45 44 86 55 85
| \/ |||    ____)   Lautrupvang 4 B    Switch: +45 44 86 55 55
  TECHNOLOGIES      DK-2750 Ballerup   Fax...: +45 44 86 55 56
                    Denmark            http://www.mips.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
  2001-11-30 23:36   ` Kjeld Borch Egevang
  (?)
@ 2001-12-02 13:12   ` Ralf Baechle
  2001-12-02 13:22     ` Geert Uytterhoeven
  -1 siblings, 1 reply; 7+ messages in thread
From: Ralf Baechle @ 2001-12-02 13:12 UTC (permalink / raw)
  To: Kjeld Borch Egevang; +Cc: Mark Salter, linux-mips

On Sat, Dec 01, 2001 at 12:36:44AM +0100, Kjeld Borch Egevang wrote:

> Great. The same problem exists for sp_tlong.c and dp_tlong.c.

Ok, this is what I'm going to checkin for both 2.4 and 2.5.  Tell me if
that's ok.

Btw, we've got so many almost identical sourcefiles in the fp emulation
code, something should be done about that ...

  Ralf

Index: arch/mips/math-emu/dp_tint.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/math-emu/dp_tint.c,v
retrieving revision 1.4
diff -u -r1.4 dp_tint.c
--- arch/mips/math-emu/dp_tint.c	2001/10/09 23:56:18	1.4
+++ arch/mips/math-emu/dp_tint.c	2001/12/02 13:10:44
@@ -50,6 +50,9 @@
 		break;
 	}
 	if (xe >= 31) {
+		/* look for valid corner case */
+		if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
+			return -2147483648;
 		/* Set invalid. We will only use overflow for floating
 		   point overflow */
 		SETCX(IEEE754_INVALID_OPERATION);
Index: arch/mips/math-emu/dp_tlong.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/math-emu/dp_tlong.c,v
retrieving revision 1.5
diff -u -r1.5 dp_tlong.c
--- arch/mips/math-emu/dp_tlong.c	2001/11/21 15:53:51	1.5
+++ arch/mips/math-emu/dp_tlong.c	2001/12/02 13:10:44
@@ -49,6 +49,9 @@
 		break;
 	}
 	if (xe >= 63) {
+		/* look for valid corner case */ 
+		if (xe == 63 && xs && xm == DP_HIDDEN_BIT)
+			return -9223372036854775808LL;
 		/* Set invalid. We will only use overflow for floating
 		   point overflow */
 		SETCX(IEEE754_INVALID_OPERATION);
Index: arch/mips/math-emu/sp_tint.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/math-emu/sp_tint.c,v
retrieving revision 1.4
diff -u -r1.4 sp_tint.c
--- arch/mips/math-emu/sp_tint.c	2001/10/09 23:56:19	1.4
+++ arch/mips/math-emu/sp_tint.c	2001/12/02 13:10:44
@@ -50,6 +50,9 @@
 		break;
 	}
 	if (xe >= 31) {
+		/* look for valid corner case */
+		if (xe == 31 && xs && xm == SP_HIDDEN_BIT)
+			return -2147483648;
 		/* Set invalid. We will only use overflow for floating
 		   point overflow */
 		SETCX(IEEE754_INVALID_OPERATION);
Index: arch/mips/math-emu/sp_tlong.c
===================================================================
RCS file: /home/pub/cvs/linux/arch/mips/math-emu/sp_tlong.c,v
retrieving revision 1.4
diff -u -r1.4 sp_tlong.c
--- arch/mips/math-emu/sp_tlong.c	2001/10/09 23:56:19	1.4
+++ arch/mips/math-emu/sp_tlong.c	2001/12/02 13:10:44
@@ -49,6 +49,9 @@
 		break;
 	}
 	if (xe >= 63) {
+		/* look for valid corner case */
+		if (xe == 63 && xs && xm == SP_HIDDEN_BIT)
+			return -9223372036854775808LL;
 		/* Set invalid. We will only use overflow for floating
 		   point overflow */
 		SETCX(IEEE754_INVALID_OPERATION);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
  2001-12-02 13:12   ` Ralf Baechle
@ 2001-12-02 13:22     ` Geert Uytterhoeven
  2001-12-02 13:40       ` Ralf Baechle
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2001-12-02 13:22 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Linux/MIPS Development

On Mon, 3 Dec 2001, Ralf Baechle wrote:
> Btw, we've got so many almost identical sourcefiles in the fp emulation
> code, something should be done about that ...

diff --ifdef :-)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
  2001-12-02 13:22     ` Geert Uytterhoeven
@ 2001-12-02 13:40       ` Ralf Baechle
  0 siblings, 0 replies; 7+ messages in thread
From: Ralf Baechle @ 2001-12-02 13:40 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Linux/MIPS Development

On Sun, Dec 02, 2001 at 02:22:56PM +0100, Geert Uytterhoeven wrote:

> On Mon, 3 Dec 2001, Ralf Baechle wrote:
> > Btw, we've got so many almost identical sourcefiles in the fp emulation
> > code, something should be done about that ...
> 
> diff --ifdef :-)

Hope Santa didn't see that ;-)

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: math emulator patch
  2001-11-30 23:36   ` Kjeld Borch Egevang
  (?)
  (?)
@ 2002-05-17 14:04   ` Kjeld Borch Egevang
  -1 siblings, 0 replies; 7+ messages in thread
From: Kjeld Borch Egevang @ 2002-05-17 14:04 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-mips

I discovered that the fix (from last year) does not work for cvt.w.d of 
e.g. 0xc1e0000000000001. Here is a patch:

Index: dp_tint.c
===================================================================
RCS file: /cvs/linux/arch/mips/math-emu/dp_tint.c,v
retrieving revision 1.5
diff -u -r1.5 dp_tint.c
--- dp_tint.c   2001/12/02 14:21:29     1.5
+++ dp_tint.c   2002/05/17 13:58:03
@@ -49,10 +49,7 @@
        case IEEE754_CLASS_NORM:
                break;
        }
-       if (xe >= 31) {
-               /* look for valid corner case */
-               if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
-                       return -2147483648;
+       if (xe > 31) {
                /* Set invalid. We will only use overflow for floating
                   point overflow */
                SETCX(IEEE754_INVALID_OPERATION);
@@ -98,7 +95,8 @@
                                xm++;
                        break;
                }
-               if ((xm >> 31) != 0) {
+               /* look for valid corner case 0x80000000 */
+               if ((xm >> 31) != 0 && (xs == 0 || xm != 0x80000000)) {
                        /* This can happen after rounding */
                        SETCX(IEEE754_INVALID_OPERATION);
                        return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);

/Kjeld


On Sat, 1 Dec 2001, Kjeld Borch Egevang wrote:

> Great. The same problem exists for sp_tlong.c and dp_tlong.c.
> 
> /Kjeld
> 
> On Thu, 29 Nov 2001, Mark Salter wrote:
> 
> > 
> > The following patch fixes the emulation of cvt.w.s and cvt.w.d for
> > values of -2147483648.
> > 
> > --Mark
> > 
> > 
> > Index: sp_tint.c
> > ===================================================================
> > RCS file: /cvs/linux/arch/mips/math-emu/sp_tint.c,v
> > retrieving revision 1.4
> > diff -u -p -5 -c -r1.4 sp_tint.c
> > cvs server: conflicting specifications of output style
> > *** sp_tint.c	2001/10/09 23:56:19	1.4
> > --- sp_tint.c	2001/11/29 19:14:58
> > *************** int ieee754sp_tint(ieee754sp x)
> > *** 48,57 ****
> > --- 48,60 ----
> >   	case IEEE754_CLASS_DNORM:
> >   	case IEEE754_CLASS_NORM:
> >   		break;
> >   	}
> >   	if (xe >= 31) {
> > + 		/* look for valid corner case */
> > + 		if (xe == 31 && xs && xm == SP_HIDDEN_BIT)
> > + 			return -2147483648;
> >   		/* Set invalid. We will only use overflow for floating
> >   		   point overflow */
> >   		SETCX(IEEE754_INVALID_OPERATION);
> >   		return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x);
> >   	}
> > Index: dp_tint.c
> > ===================================================================
> > RCS file: /cvs/linux/arch/mips/math-emu/dp_tint.c,v
> > retrieving revision 1.4
> > diff -u -p -5 -c -r1.4 dp_tint.c
> > cvs server: conflicting specifications of output style
> > *** dp_tint.c	2001/10/09 23:56:18	1.4
> > --- dp_tint.c	2001/11/29 19:18:02
> > *************** int ieee754dp_tint(ieee754dp x)
> > *** 48,57 ****
> > --- 48,60 ----
> >   	case IEEE754_CLASS_DNORM:
> >   	case IEEE754_CLASS_NORM:
> >   		break;
> >   	}
> >   	if (xe >= 31) {
> > + 		/* look for valid corner case */
> > + 		if (xe == 31 && xs && xm == DP_HIDDEN_BIT)
> > + 			return -2147483648;
> >   		/* Set invalid. We will only use overflow for floating
> >   		   point overflow */
> >   		SETCX(IEEE754_INVALID_OPERATION);
> >   		return ieee754si_xcpt(ieee754si_indef(), "dp_tint", x);
> >   	}
> > 
> 
> 

-- 
_    _ ____  ___                       Mailto:kjelde@mips.com
|\  /|||___)(___    MIPS Denmark       Direct: +45 44 86 55 85
| \/ |||    ____)   Lautrupvang 4 B    Switch: +45 44 86 55 55
  TECHNOLOGIES      DK-2750 Ballerup   Fax...: +45 44 86 55 56
                    Denmark            http://www.mips.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-05-17 14:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-30  1:38 math emulator patch Mark Salter
2001-11-30 23:36 ` Kjeld Borch Egevang
2001-11-30 23:36   ` Kjeld Borch Egevang
2001-12-02 13:12   ` Ralf Baechle
2001-12-02 13:22     ` Geert Uytterhoeven
2001-12-02 13:40       ` Ralf Baechle
2002-05-17 14:04   ` Kjeld Borch Egevang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.