[m-dev.] float regression
Peter Wang
novalazy at gmail.com
Fri Aug 26 17:27:50 AEST 2011
On 2011-08-25, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> When investigating a test case failure, I came across this difference
> between the code of library/float.c in grade hlc.gc:
>
> --- library/float.c 2011-08-25 14:39:59.968258931 +1000
> +++ stage2/library/float.c 2011-08-25 14:50:45.312467217 +1000
> @@ -974,7 +974,7 @@
>
> mercury__float__succeeded = (mercury__float__Num_3 <= mercury__float__V_5_5);
> if (mercury__float__succeeded)
> - mercury__float__Abs_4 = (((MR_Float) 0.0000000000000000) - mercury__float__Num_3);
> + mercury__float__Abs_4 = (((MR_Float) 5.9154716928082453e-317) - mercury__float__Num_3);
> else
> mercury__float__Abs_4 = mercury__float__Num_3;
> return mercury__float__Abs_4;
> @@ -1175,7 +1175,7 @@
> {
> {
> MR_bool mercury__float__succeeded;
> - MR_Float mercury__float__HeadVar__2_2 = (((MR_Float) 0.0000000000000000) - mercury__float__HeadVar__1_1);
> + MR_Float mercury__float__HeadVar__2_2 = (((MR_Float) 5.9154716928082453e-317) - mercury__float__HeadVar__1_1);
>
> return mercury__float__HeadVar__2_2;
> }
>
> library/float.c was generated by a compiler I installed on my laptop on Aug 16,
> while stage2/library/float.c was generated by an up-to-date compiler.
> The differences are in the implementation of the absolute value function
> and the unary minus function. There is a similar difference in math.c.
>
> The test case failures I was investigating are in tests/term, and involve
> differences in the output of the old termination analysis system, which uses
> float math, some of which is sensitive to such imprecision. I don't know
> for certain yet, but these diffs could have caused the test case failures.
>
> This seems to me to be a clear regression. Peter, can you please look into
> whether one of your changes to floats caused this?
I think I understand what's going on.
The source of the strange float is:
builtin_translation("float", "-", 0, [X, Y],
assign(Y, binary(float_minus, float_const(0.0), leaf(X)))).
specifically, the static term `float_const(0.0)'.
I committed my unboxed float patch on Aug 22. If the bootstrap compiler
is from before Aug 22, it will generate a static term with a boxed float
representation.
However, the change also modified the MR_unbox_float() macro to NOT
expect boxed floats on 64-bit platforms. So a pointer is being
interpreted as a float.
The issue does not arise with rotd-2011-08-23 as the bootstrap compiler.
Peter
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list