Date: Mon, 21 Nov 2016 16:28:30 +0300 From: Michael Zhilin <mizhka@gmail.com> To: Eugene Grosbein <eugen@grosbein.net> Cc: Warner Losh <imp@bsdimp.com>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org> Subject: Re: MIPS code size strangeness Message-ID: <CAF19XBKAa%2Bjj4GdfugY2C2aGzyFNhDXob5RH29tgG41Ov6Jx1A@mail.gmail.com> In-Reply-To: <5832D7F4.9090206@grosbein.net> References: <5831E800.60003@grosbein.net> <CANCZdfpMLQm58kuHkPzqfrw6Ks5jPK5YLb9mDnANYfWDXggcAQ@mail.gmail.com> <5832D7F4.9090206@grosbein.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Eugene, To disassemble code you can use binutils, but I prefer radare2 (devel/radare2). I've checked both (disclaimer: I'm familiar with MIPS instruction set, but not with x86), and it looks like x86 version uses extra optimization available for x86 platform (XMM instructions): ||| 0x000180e3 66480f6ec1 movq xmm0, rcx ||| 0x000180e8 660f62050035. punpckldq xmm0, xmmword [0x0001b5f0] ||| 0x000180f0 660f5c050835. subpd xmm0, xmmword [0x0001b600] ||| 0x000180f8 660f70c84e pshufd xmm1, xmm0, 0x4e ||| 0x000180fd 660f58c8 addpd xmm1, xmm0 ; 'r' ||| 0x00018101 f20f590d1735. mulsd xmm1, qword [0x0001b620] ||| 0x00018109 f20f10051735. movsd xmm0, qword [0x0001b628] ; [0x1b628:8]=0x43e0000000000000 ||| 0x00018111 660f28d1 movapd xmm2, xmm1 ||| 0x00018115 f20f5cd0 subsd xmm2, xmm0 ||| 0x00018119 f2480f2cc2 cvttsd2si rax, xmm2 ||| 0x0001811e 48b900000000. movabs rcx, -0x8000000000000000 ||| 0x00018128 4831c1 xor rcx, rax ||| 0x0001812b f2480f2cf1 cvttsd2si rsi, xmm1 ||| 0x00018130 660f2ec8 ucomisd xmm1, xmm0 ||| 0x00018134 480f43f1 cmovae rsi, rcx But MIPS instruction set is not so rich for math operations as x86, even "find first set" command is not exists. So implementation of hash functions compiled on MIPS can be long. I suppose it's good place for optimizations. Thanks! On Mon, Nov 21, 2016 at 2:18 PM, Eugene Grosbein <eugen@grosbein.net> wrote: > On 21.11.2016 05:18, Warner Losh wrote: > > On Sun, Nov 20, 2016 at 11:14 AM, Eugene Grosbein <eugen@grosbein.net> > wrote: > >> Hi! > >> > >> I'm currently struggle trying to fit my FreeBSD 12/mips build into 8M > flash available. > >> It used to fit with early 11.0-CURRENT and it has over megabyte > overhead with 12.0-CURRENT. > >> > >> Large parts are /usr/bin and /usr/lib and I've found something very > strange. > >> For example: /usr/lib/libprivateucl.so.1 has 136064 bytes for amd64 > >> and it has 241560 bytes for mips. > >> > >> "nm -C -D --print-size --size-sort libprivateucl.so.1" shows the symbol > "ucl_hash_replace" > >> has 330 bytes (0x14a) for amd64 and it has 25000 bytes (sic! 0x61a8) > for mips. > >> > >> I understand that amd64 version is built with clang and MIPS code > generated with gcc. > >> But why such large difference? In no way such small function > ucl_hash_replace() > >> should expand to 25000 machine code bytes. > >> > >> I suspect other parts of code may have this problem too. > > > > Keep in mind that FreeBSD uses clang for amd64, which is quite good at > > code generation, while we still have to use an ancient version of gcc > > for mips, which is known to produce kinda crappy code for mips. To > > know for sure, you'll need to look at the code. > > C code is pretty small and simple. How do I disassemble MIPS machine code? > > Is it possible to build FreeBSD12/mips with something more modern like > gcc6, perhaps? > > > _______________________________________________ > freebsd-mips@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-mips > To unsubscribe, send any mail to "freebsd-mips-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF19XBKAa%2Bjj4GdfugY2C2aGzyFNhDXob5RH29tgG41Ov6Jx1A>