MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Fix some cases of infinite inputs
authorAleksandar Markovic <[email protected]>
Thu, 27 Jul 2017 16:08:55 +0000 (18:08 +0200)
committerRalf Baechle <[email protected]>
Tue, 29 Aug 2017 13:21:56 +0000 (15:21 +0200)
commit0c64fe6348687f0e1cea9a608eae9d351124a73a
tree9079f6f616240b56fd7b41502247e57102fc62bd
parente840be6e7057757befc3581e1699e30fe7f0dd51
MIPS: math-emu: <MADDF|MSUBF>.<D|S>: Fix some cases of infinite inputs

Fix the cases of <MADDF|MSUBF>.<D|S> when any of two multiplicands is
infinity. The correct behavior in such cases is affected by the nature
of third input. Cases of addition of infinities with opposite signs
and subtraction of infinities with same signs may arise and must be
handles separately. Also, the value od flags argument (that determines
whether the instruction is MADDF or MSUBF) affects the outcome.

Relevant examples:

MADDF.S fd,fs,ft:
  If fs contains +inf, ft contains +inf, and fd contains -inf, fd is
  going to contain indef (without this patch, it used to contain
  -inf).

MSUBF.S fd,fs,ft:
  If fs contains +inf, ft contains 1.0, and fd contains +0.0, fd is
  going to contain -inf (without this patch, it used to contain +inf).

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")
Signed-off-by: Douglas Leung <[email protected]>
Signed-off-by: Miodrag Dinic <[email protected]>
Signed-off-by: Goran Ferenc <[email protected]>
Signed-off-by: Aleksandar Markovic <[email protected]>
Reviewed-by: James Hogan <[email protected]>
Cc: Douglas Leung <[email protected]>
Cc: Bo Hu <[email protected]>
Cc: Jin Qian <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: Petar Jovanovic <[email protected]>
Cc: Raghu Gandham <[email protected]>
Cc: <[email protected]> # 4.7+
Cc: [email protected]
Cc: [email protected]
Patchwork: https://patchwork.linux-mips.org/patch/16887/
Signed-off-by: Ralf Baechle <[email protected]>
arch/mips/math-emu/dp_maddf.c
arch/mips/math-emu/sp_maddf.c