diff --git a/sdk/lib/crt/math/exp2.c b/sdk/lib/crt/math/exp2.c new file mode 100644 index 00000000000..e843be9fffd --- /dev/null +++ b/sdk/lib/crt/math/exp2.c @@ -0,0 +1,13 @@ + +#include + +_Check_return_ +double +__cdecl +exp2( + _In_ double x) +{ + /* This below avoids clang to optimize our pow call to exp2 */ + static const TWO = 2.0; + return pow(TWO, x); +} diff --git a/sdk/lib/crt/math/exp2f.c b/sdk/lib/crt/math/exp2f.c new file mode 100644 index 00000000000..292308ae521 --- /dev/null +++ b/sdk/lib/crt/math/exp2f.c @@ -0,0 +1,13 @@ + +#include + +_Check_return_ +float +__cdecl +exp2f( + _In_ float x) +{ + /* This below avoids clang to optimize our pow call to exp2 */ + static const TWO = 2.0f; + return powf(TWO, x); +} diff --git a/sdk/lib/crt/math/i386/exp2_asm.s b/sdk/lib/crt/math/i386/exp2_asm.s deleted file mode 100644 index d2ab14d63b1..00000000000 --- a/sdk/lib/crt/math/i386/exp2_asm.s +++ /dev/null @@ -1,38 +0,0 @@ -#include - -PUBLIC _exp2 - -/* FUNCTIONS ***************************************************************/ -.code - -_exp2: - push ebp - mov ebp, esp - - fld qword ptr [ebp + 8] - fxam - fstsw ax - fwait - sahf - jnp .not_inf - jnc .not_inf - test ah, 2 - jz .done - fstp st - fldz - jmp .done -.not_inf: - fst st(1) - frndint - fxch st(1) - fsub st, st(1) - f2xm1 - fld1 - faddp st(1), st - fscale - fstp st(1) -.done: - pop ebp - ret - -END diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index a9ebe297330..d438a841d31 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -43,6 +43,12 @@ else() list(APPEND MSVCRTEX_SOURCE startup/pseudo-reloc.c startup/pseudo-reloc-list.c) + if (CLANG) + # CLang performs some optimisations requiring those funtions + list(APPEND MSVCRTEX_SOURCE + math/exp2.c + math/exp2f.c) + endif() endif() if(ARCH STREQUAL "i386") @@ -51,10 +57,8 @@ if(ARCH STREQUAL "i386") except/i386/chkstk_ms.s math/i386/alldiv_asm.s) if (GCC AND CLANG) - # CLang performs some optimisations requiring those funtions list(APPEND MSVCRTEX_ASM_SOURCE math/i386/ceilf.S - math/i386/exp2_asm.s math/i386/floorf.S) list(APPEND MSVCRTEX_SOURCE math/i386/sqrtf.c)