From owner-freebsd-mips@freebsd.org Mon Nov 21 13:28:33 2016 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87B9FC4CB81 for ; Mon, 21 Nov 2016 13:28:33 +0000 (UTC) (envelope-from mizhka@gmail.com) Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1364F19BA for ; Mon, 21 Nov 2016 13:28:33 +0000 (UTC) (envelope-from mizhka@gmail.com) Received: by mail-wm0-x22d.google.com with SMTP id f82so144988540wmf.1 for ; Mon, 21 Nov 2016 05:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=H6Ipl4my+DKkWWV8NczsxpgaRBaoXqI6Hbcsb59fvTQ=; b=iqRdR2Z6Hm8OQNIdqreBx4m6T8+zwUNVi8p62uVbludmdKOOrxxFpfSISvxJtckXD9 5HP3cFTrzTVWOgqo59RWb0ZeX75K3l/Yp8+1Is0IDb1kLXsrFuJjyoxZFeAMyx0dTJ3O R3cJDUFssNWnhW1sGQhd4VFSwSlToleqhdwbcIjWnXKU8tZCth6yAIq2LUYwJYrItbq9 0uJ++5Jl1ItMUtBf1+2/VglMTWB5rjILYqsRbpGqYdya7xj7/wU56Pv1EyMPQR3Iu9iJ Vqa+E08xKZ4Pkc5UcAt5k64uULS04lost8nigejvVge8mtiu/ISFl71M4yUK6jUkw7pF I6lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=H6Ipl4my+DKkWWV8NczsxpgaRBaoXqI6Hbcsb59fvTQ=; b=S/iKLL1SE4etg1Q4w7mqvuV4iCPxokkIF7yuCXVOx6Mn8O66GEpqu9XivI2fqUBppk S8jVfTZmdXv66FzGsseGUU5L1Llam+Rh0OtVyU8wGOgJWcLIADNefhmZbxeVrXX84pQq NmWPe2NoyvGxZWXTgWsb3fREiR/TiuIhcBJbdZh3xAJp0C1LUqzjNHDy8BzxKPixC7Y+ FmFn9E2xG58StczvL0HzozKiuCsEk2IvEqs3OCswbvaMWJQ3gxyfW3y2mWsPyxyZDdsZ LBkAJnUrzn0jU7yFXVd3oJGuKAD1KTWRleckSiXZ8f027sCfX8tJXYKGzbnhtYm79JII ACNA== X-Gm-Message-State: AKaTC00WzzO0cX22FfZ3d3tniI04/mhEGO1GNJomPW/oVtAhW0oZKVYrwwoxGOx6nZaIg4RqsyUH+y3ilkTLvg== X-Received: by 10.28.113.218 with SMTP id d87mr14489255wmi.111.1479734911148; Mon, 21 Nov 2016 05:28:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.152.131 with HTTP; Mon, 21 Nov 2016 05:28:30 -0800 (PST) In-Reply-To: <5832D7F4.9090206@grosbein.net> References: <5831E800.60003@grosbein.net> <5832D7F4.9090206@grosbein.net> From: Michael Zhilin Date: Mon, 21 Nov 2016 16:28:30 +0300 Message-ID: Subject: Re: MIPS code size strangeness To: Eugene Grosbein Cc: Warner Losh , "freebsd-mips@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 13:28:33 -0000 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 wrote: > On 21.11.2016 05:18, Warner Losh wrote: > > On Sun, Nov 20, 2016 at 11:14 AM, Eugene Grosbein > 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" >