[PATCH 2/2]: FastFPE 'cmf' fix for zero comparisons
FastFPE's implementation of the 'cmf' and 'cnf' opcodes incorrectly treat
+0 and -0 as inequal numbers, which violates IEEE 754.
The enclosed patch fixes this bug by testing for the
magic exponent that indicates 'zero' before testing the signs of the
comparison operands.
Minimal test cases that illustrate the problem are at
<http://www.booyaka.com/~paul/arm/fpa11_cmf_tests.tar.gz>. After patching
with the patch below, the result of the test cases is identical between
NWFPE and FastFPE. (The test cases are derived from code posted earlier
by Nicholas Clark <nick@unfortu.net> - thanks!)
This patch applies cleanly against 2.4.19-rmk2 and 2.5.30-rmk1. (This is
also true for the previous 'lfm' patch.)
Thanks again to Tony Lindgren <tony@atomide.org> for his help with
catching this bug.
- Paul
--- linux-2.4.19-rmk2/arch/arm/fastfpe/CPRT.S Wed Sep 25 01:38:54 2002
+++ linux-2.4.19-rmk2-pjw/arch/arm/fastfpe/CPRT.S.new Wed Sep 25 01:36:08 2002
@@ -128,6 +128,10 @@
cmp r8,#0x7fffffff
cmpeq r4,#0xffffffff
beq CPRT_cmf_unordered
+
+ cmp r7,#0x80000000 @ zero can be either positive or negative,
+ cmpeq r8,#0x80000000 @ but +0 is equal to -0 in IEEE 754
+ beq CPRT_cmf_equal
cmp r1,r2
beq CPRT_cmf_equalsign
Reply to: