Skip to contentSkip to conversation

Patch "MIPS: math-emu: <MADDF|MSUBF>.S: Fix accuracy (32-bit case)" has been added to the 4.13-stable tree

PATCH [email protected] 1 participant 1 message Sep 21, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

MIPS: math-emu: <MADDF|MSUBF>.S: Fix accuracy (32-bit case)

to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mips-math-emu-maddf-msubf-.s-fix-accuracy-32-bit-case.patch
and it can be found in the queue-4.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From b3b8e1eb27c523e32b6a8aa7ec8ac4754456af57 Mon Sep 17 00:00:00 2001

From: Douglas Leung <[email protected]>
Date: Thu, 27 Jul 2017 18:08:58 +0200
Subject: MIPS: math-emu: <MADDF|MSUBF>.S: Fix accuracy (32-bit case)

From: Douglas Leung <[email protected]>

commit b3b8e1eb27c523e32b6a8aa7ec8ac4754456af57 upstream.

Implement fused multiply-add with correct accuracy.

Fused multiply-add operation has better accuracy than respective sequential execution of multiply and add operations applied on the same inputs. This is because accuracy errors accumulate in latter case.

This patch implements fused multiply-add with the same accuracy as it is implemented in hardware, using 64-bit intermediate calculations.

One test case example (raw bits) that this patch fixes:

MADDF.S fd,fs,ft:
fd = 0x22575225
fs = ft = 0x3727c5ac

Fixes e24c3bec3e8e ("MIPS: math-emu: Add support for the MIPS R6 MADDF FPU instruction")
Fixes 83d43305a1df ("MIPS: math-emu: Add support for the MIPS R6 MSUBF FPU instruction")

Patchwork: https://patchwork.linux-mips.org/patch/16890/

---
 arch/mips/math-emu/ieee754sp.h |    4 +
 arch/mips/math-emu/sp_maddf.c  |  116 ++++++++++++++++-------------------------
 2 files changed, 50 insertions(+), 70 deletions(-)
arch/mips/math-emu/ieee754sp.h +4 -0
@@ -45,6 +45,10 @@ static inline int ieee754sp_finite(union
 	return SPBEXP(x) != SP_EMAX + 1 + SP_EBIAS;
 }
 
+/* 64 bit right shift with rounding */
+#define XSPSRS64(v, rs)						\
+	(((rs) >= 64) ? ((v) != 0) : ((v) >> (rs)) | ((v) << (64-(rs)) != 0))
+
 /* 3bit extended single precision sticky right shift */
 #define XSPSRS(v, rs)						\
 	((rs > (SP_FBITS+3))?1:((v) >> (rs)) | ((v) << (32-(rs)) != 0))
arch/mips/math-emu/sp_maddf.c +46 -70

168 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-nan-propagation.patch queue-4.13/mips-math-emu-max-maxa-min-mina-.-d-s-fix-cases-of-both-inputs-zero.patch queue-4.13/mips-math-emu-max-min-.-d-s-fix-cases-of-both-inputs-negative.patch queue-4.13/mips-math-emu-max-maxa-min-mina-.-d-s-fix-quiet-nan-propagation.patch queue-4.13/mips-math-emu-maddf-msubf-.d-fix-accuracy-64-bit-case.patch queue-4.13/mips-math-emu-maddf-msubf-.s-fix-accuracy-32-bit-case.patch queue-4.13/mips-math-emu-maxa-mina-.-d-s-fix-cases-of-input-values-with-opposite-signs.patch queue-4.13/mips-math-emu-maxa-mina-.-d-s-fix-cases-of-both-infinite-inputs.patch queue-4.13/mips-math-emu-mina.-d-s-fix-some-cases-of-infinity-and-zero-inputs.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-some-cases-of-zero-inputs.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-clean-up-maddf_flags-enumeration.patch queue-4.13/mips-math-emu-maddf-msubf-.-d-s-fix-some-cases-of-infinite-inputs.patch