-
Notifications
You must be signed in to change notification settings - Fork 34
Description
On s390x (with hardware dfp) the test test-cast-to-overflow fails with:
3 Error: Expected: "0x1.fffffffffffffp+1023"
Result: "inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:49
4 Error: Expected: "-0x1.fffffffffffffp+1023"
Result: "-inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:50
5 Error: Expected: "0x1.fffffffffffffp+1023"
Result: "inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:51
8 Error: Expected: "-0x1.fffffffffffffp+1023"
Result: "-inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:54
11 Error: Expected: "0x1.fffffep+127"
Result: "inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:61
12 Error: Expected: "-0x1.fffffep+127"
Result: "-inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:62
13 Error: Expected: "0x1.fffffep+127"
Result: "inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:63
16 Error: Expected: "-0x1.fffffep+127"
Result: "-inf"
in: /home/stli/libdfpDir/src/tests/test-cast-to-overflow.c:66
Found 8 failures.
and test-cast-to-underflow with:
5 Error: Expected: "0x0.0000000000001p-1022"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:51
6 Error: Expected: "-0x0.0000000000001p-1022"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:52
10 Error: Expected: "-0x0.0000000000001p-1022"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:56
11 Error: Expected: "0x0.0000000000001p-1022"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:57
17 Error: Expected: "0x1p-149"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:67
18 Error: Expected: "-0x1p-149"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:68
22 Error: Expected: "-0x1p-149"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:72
23 Error: Expected: "0x1p-149"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:73
Found 8 failures.
The main cause of those fails on s390x is, that the pfpo instruction is used to convert from dfp to bfp values, but unfortunately, GCC emits the pfpo instruction with RM-mode 0 = "According to current DFP rounding mode in bits 25-27 of the floating-point-control register".
Future GCCs (>8.1) have to use RM-mode 1 = "According to current BFP rounding mode in bits 29-31 of the floating-point-control register"
After patching the test-binary in order to use RM-mode 1 or by adding fe_dec_setround() calls, the most tests are passing on s390x.
But there are still the following fails in test-cast-to-underflow:
5 Error: Expected: "0x0.0000000000001p-1022"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:51
// {LINE, FE_TONEAREST, 2.4703282292062326e-325DL, DBL_DENORM_MIN},
6 Error: Expected: "-0x0.0000000000001p-1022"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:52
// {LINE, FE_TONEAREST, -2.4703282292062326e-325DL, -DBL_DENORM_MIN},
17 Error: Expected: "0x1p-149"
Result: "0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:67
// {LINE, FE_TONEAREST, 7.0064922e-46DL, FLT_DENORM_MIN},
18 Error: Expected: "-0x1p-149"
Result: "-0x0p+0"
in: /home/stli/libdfpDir/src/tests/test-cast-to-underflow.c:68
// {LINE, FE_TONEAREST, -7.0064922e-46DL, -FLT_DENORM_MIN},
It seems as the tests use incorrect input values or assumptions.
According to the comment from Joseph Myers in "Conversions incorrect on underflow #32" (#32), "This fix looks wrong for FE_TONEAREST mode, when conversion of a value with absolute value less than or equal to half the least subnormal in the target type should produce +/- 0, not +/- the least subnormal."
The following min-values are defined for the bfp types:
define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
define __DBL_DENORM_MIN__ ((double)4.94065645841246544176568792868221372e-324L)
define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
=> half of the least subnormal (DBL_DENORM_MIN) = 2.4703282292062327e-324.
And not 2.4...26e-325.
=> half of the least subnormal (FLT_DENORM_MIN) = 7.0064923e-46
And not 7.0...22e-46.
Thus the tests should be adjusted in order to use the correct input values and assumptions.
Furthermore, there seems to be a typo in some/all the truncation conversions.
See commit "Fix subnormals for decimal to binary conversions." (4f67ffa):
-In commit-message: "It should return -0.0/0.0 if the absolute value of the result is less than or equal to half the least subnormal or subnormal otherwise (task #32)."
-In code:
if (... || (exp == ... && (mant >= (POWOF10_MIN_DENORM_DBL_MAN/2LL))))
return SIGNBIT(a) ? -0.0 : 0.0;
else
return SIGNBIT(a) ? -__DBL_DENORM_MIN__ : __DBL_DENORM_MIN__;
@racardoso Can you have a look at your commit?