Subject: fpu problem
To: None <eeh@netbsd.org>
From: Jason Wright <jason@thought.net>
List: port-sparc64
Date: 09/10/2001 13:35:23
I just committed a fix to OpenBSD's tree to an fpu problem that affects both
OpenBSD and NetBSD.  The problem is the mask for rd is applied based on the
type, which isn't correct for the F?TO? instructions.  The fix is to fix up
rd when executing the instruction based on the destination type.

Patch below (against netbsd current) Usual caveat applies... I have not
actually tested this on NetBSD, but a very similiar diff fixes my test
vectors (AT&T awk length() function) on OpenBSD.  The same awk code fails
in the same way on NetBSD currently when using AT&T awk.

--Jason L. Wright

Index: fpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc/fpu/fpu.c,v
retrieving revision 1.11
diff -u -r1.11 fpu.c
--- fpu.c	2000/12/06 01:47:50	1.11
+++ fpu.c	2001/09/10 17:32:56
@@ -527,14 +527,22 @@
 	case FTOX >> 2:
 		DPRINTF(FPE_INSN, ("fpu_execute: FTOx\n"));
 		fpu_explode(fe, fp = &fe->fe_f1, type, rs2);
+		rd = instr.i_opf.i_rd & (~1);
 		type = FTYPE_LNG;
 		break;
 #endif /* SUN4U */
 
 	case FTOS >> 2:
+	case FTOI >> 2:
+		rd = instr.i_opf.i_rd;
+		goto fto;
 	case FTOD >> 2:
+		rd = instr.i_opf.i_rd & (~1);
+		goto fto;
 	case FTOQ >> 2:
-	case FTOI >> 2:
+		rd = instr.i_opf.i_rd & (~3);
+
+fto:
 		DPRINTF(FPE_INSN, ("fpu_execute: FTOx\n"));
 		fpu_explode(fe, fp = &fe->fe_f1, type, rs2);
 		type = opf & 3;	/* sneaky; depends on instruction encoding */