Skip to content

[builtins] inaccurate results from divdc3 on x86_64 darwin10 #9522

@llvmbot

Description

@llvmbot
Bugzilla Link 9150
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @asl,@lattner,@vitalybuka,@zsrkmyn

Extended Description

The lazy implementation of divdc3 in compiler-rt results in accurate results for the following test...

--- divdc3_test.c.sav 2011-02-05 15:56:15.000000000 -0500
+++ divdc3_test.c 2011-02-05 16:46:31.000000000 -0500
@@ -49,8 +49,8 @@
int test__divdc3(double a, double b, double c, double d)
{
double _Complex r = __divdc3(a, b, c, d);
-// printf("test__divdc3(%f, %f, %f, %f) = %f + I%f\n",
-// a, b, c, d, creal(r), cimag(r));

  • printf("test__divdc3(%f, %f, %f, %f) = %f + I%f\n",
    
  •         a, b, c, d, creal(r), cimag(r));
    
    double _Complex dividend;
    double _Complex divisor;

@@ -365,6 +365,7 @@
return 1;
}
}

  • test__divdc3(DBL_MAX * 0.5, DBL_MAX * 0.5,DBL_MAX * 0.25, DBL_MAX * 0.25);

    return 0;
    }

which produces the inaccurate results...

gcc -I ../../lib divdc3_test.c ../../darwin_fat/Release/libcompiler_rt.a
./a.out
....
test__divdc3(89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184.000000, 89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184.000000, 44942328371557892703631855932926089199517641881461249149729369200789315195007134690147389658191719542885114738378595616058580331722366045692116886675884379246512477644137820519061372522597332236018967127113783485576145809225805737041452139833030837068699456551036180792184544295229824970312601006546031214592.000000, 44942328371557892703631855932926089199517641881461249149729369200789315195007134690147389658191719542885114738378595616058580331722366045692116886675884379246512477644137820519061372522597332236018967127113783485576145809225805737041452139833030837068699456551036180792184544295229824970312601006546031214592.000000) = inf + I0.000000

compared to the accurate implementation of divdc3 in FSF gcc's libgcc...

gcc-4 -I ../../lib divdc3_test.c /sw/lib/gcc4.6/lib/gcc/x86_64-apple-darwin10.7.0/4.6.0/libgcc.a
./a.out
...
test__divdc3(89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184.000000, 89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184.000000, 44942328371557892703631855932926089199517641881461249149729369200789315195007134690147389658191719542885114738378595616058580331722366045692116886675884379246512477644137820519061372522597332236018967127113783485576145809225805737041452139833030837068699456551036180792184544295229824970312601006546031214592.000000, 44942328371557892703631855932926089199517641881461249149729369200789315195007134690147389658191719542885114738378595616058580331722366045692116886675884379246512477644137820519061372522597332236018967127113783485576145809225805737041452139833030837068699456551036180792184544295229824970312601006546031214592.000000) = 2.000000 + I0.000000

Not fixing this bug degrades the utility of compiler-rt for scientific applications.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions