From b78751051f4b386899fb82054fc008f9dad73432 Mon Sep 17 00:00:00 2001 From: David Senoner Date: Fri, 4 Jul 2025 13:13:30 +0200 Subject: [PATCH] delete superfluous assembly libc floor implementations --- lib/libc/mingw/math/x86/floorf.S | 51 ---------------------- lib/libc/mingw/math/x86/floorl.S | 63 ---------------------------- lib/libc/musl/src/math/i386/floor.s | 17 +------- lib/libc/musl/src/math/i386/floorf.s | 1 - lib/libc/musl/src/math/i386/floorl.s | 1 - src/libs/mingw.zig | 2 - src/libs/musl.zig | 2 - 7 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 lib/libc/mingw/math/x86/floorf.S delete mode 100644 lib/libc/mingw/math/x86/floorl.S delete mode 100644 lib/libc/musl/src/math/i386/floorf.s delete mode 100644 lib/libc/musl/src/math/i386/floorl.s diff --git a/lib/libc/mingw/math/x86/floorf.S b/lib/libc/mingw/math/x86/floorf.S deleted file mode 100644 index c6226f82b5efc4f54dff41d586ca4244b5f1e52c..0000000000000000000000000000000000000000 --- a/lib/libc/mingw/math/x86/floorf.S +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ - #include <_mingw_mac.h> - - .file "floorf.S" - .text - .p2align 4,,15 - .globl __MINGW_USYMBOL(floorf) - .def __MINGW_USYMBOL(floorf); .scl 2; .type 32; .endef -#ifdef __x86_64__ - .seh_proc __MINGW_USYMBOL(floorf) -#endif -__MINGW_USYMBOL(floorf): -#if defined(_AMD64_) || defined(__x86_64__) - subq $40, %rsp - .seh_stackalloc 40 - .seh_endprologue - unpcklps %xmm0, %xmm0 - cvtps2pd %xmm0, %xmm0 - call floor - unpcklpd %xmm0, %xmm0 - cvtpd2ps %xmm0, %xmm0 - addq $40, %rsp - ret - .seh_endproc - .def __MINGW_USYMBOL(floor); .scl 2; .type 32; .endef -#elif defined(_X86_) || defined(__i386__) - flds 4(%esp) - subl $8,%esp - - fstcw 4(%esp) /* store fpu control word */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldcw 4(%esp) /* restore original control word */ - - addl $8,%esp - ret -#endif diff --git a/lib/libc/mingw/math/x86/floorl.S b/lib/libc/mingw/math/x86/floorl.S deleted file mode 100644 index 6a08d590a116373ae20e13da1c709e18b63f4112..0000000000000000000000000000000000000000 --- a/lib/libc/mingw/math/x86/floorl.S +++ /dev/null @@ -1,63 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include <_mingw_mac.h> - - .file "floorl.S" - .text -#ifdef __x86_64__ - .align 8 -#else - .align 4 -#endif - .globl __MINGW_USYMBOL(floorl) - .def __MINGW_USYMBOL(floorl); .scl 2; .type 32; .endef -__MINGW_USYMBOL(floorl): -#if defined(_AMD64_) || defined(__x86_64__) - fldt (%rdx) - subq $24,%rsp - - fstcw 8(%rsp) /* store fpu control word */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 8(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,(%rsp) - fldcw (%rsp) /* load modified control word */ - - frndint /* round */ - - fldcw 8(%rsp) /* restore original control word */ - - addq $24,%rsp - movq %rcx,%rax - movq $0,8(%rcx) - fstpt (%rcx) - ret -#elif defined(_X86_) || defined(__i386__) - fldt 4(%esp) - subl $8,%esp - - fstcw 4(%esp) /* store fpu control word */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldcw 4(%esp) /* restore original control word */ - - addl $8,%esp - ret -#endif diff --git a/lib/libc/musl/src/math/i386/floor.s b/lib/libc/musl/src/math/i386/floor.s index 46ba88db535dbd16161fdd95d441c9ea9066eb61..2571fb3ded463336cdc988a1f59a2fe6fb0b3b7c 100644 --- a/lib/libc/musl/src/math/i386/floor.s +++ b/lib/libc/musl/src/math/i386/floor.s @@ -1,20 +1,5 @@ -.global floorf -.type floorf,@function -floorf: - flds 4(%esp) - jmp 1f +/* zig patch: removed `floorl` and `floorf` in favor of using zig compiler_rt's implementations */ -.global floorl -.type floorl,@function -floorl: - fldt 4(%esp) - jmp 1f - -.global floor -.type floor,@function -floor: - fldl 4(%esp) -1: mov $0x7,%al 1: fstcw 4(%esp) mov 5(%esp),%ah mov %al,5(%esp) diff --git a/lib/libc/musl/src/math/i386/floorf.s b/lib/libc/musl/src/math/i386/floorf.s deleted file mode 100644 index bc29f15ce79215d44fb6a5f2c03e12d25bdb81e2..0000000000000000000000000000000000000000 --- a/lib/libc/musl/src/math/i386/floorf.s +++ /dev/null @@ -1 +0,0 @@ -# see floor.s diff --git a/lib/libc/musl/src/math/i386/floorl.s b/lib/libc/musl/src/math/i386/floorl.s deleted file mode 100644 index bc29f15ce79215d44fb6a5f2c03e12d25bdb81e2..0000000000000000000000000000000000000000 --- a/lib/libc/musl/src/math/i386/floorl.s +++ /dev/null @@ -1 +0,0 @@ -# see floor.s diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index c978a651a0f3c020e1a5951a0f25dc61f6c09566..a8c7ab3c3b4cfacb2bcb453ef79bf114fa8f5484 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -931,7 +931,6 @@ const mingw32_x86_src = [_][]const u8{ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expm1l.c", - "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorl.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodl.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fucom.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ilogbl.S", @@ -975,7 +974,6 @@ const mingw32_x86_32_src = [_][]const u8{ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S", - "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorf.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c", }; diff --git a/src/libs/musl.zig b/src/libs/musl.zig index aece219ab5daa9a22501a232f1dde3a20612ed5f..e0a6ee6b45016d80eaf98ca1eadb6b47af511b41 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -953,8 +953,6 @@ const src_files = [_][]const u8{ "musl/src/math/i386/exp_ld.s", "musl/src/math/i386/expl.s", "musl/src/math/i386/expm1l.s", - "musl/src/math/i386/floorf.s", - "musl/src/math/i386/floorl.s", "musl/src/math/i386/floor.s", "musl/src/math/i386/fmod.c", "musl/src/math/i386/fmodf.c", -- 2.54.0