From: Joe Perches <joe@perches.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, hauke@hauke-m.de, mcarlson@broadcom.com,
mchan@broadcom.com, nsujir@broadcom.com
Subject: Re: [RFC PATCH] tg3: Convert chip type macros to inline functions
Date: Sun, 10 Feb 2013 17:34:05 -0800 [thread overview]
Message-ID: <1360546445.2028.8.camel@joe-AO722> (raw)
In-Reply-To: <20130210.193927.632140014473940921.davem@davemloft.net>
On Sun, 2013-02-10 at 19:39 -0500, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Wed, 06 Feb 2013 15:44:58 -0800
>
> > To me the negative to these conversions is at
> > least for gcc 4.7.2, the overall code size
> > increases
> >
> > $ size drivers/net/ethernet/broadcom/tg3.o*
> > text data bss dec hex filename
> > 203426 13446 55744 272616 428e8 drivers/net/ethernet/broadcom/tg3.o.new
> > 202135 13446 55144 270725 42185 drivers/net/ethernet/broadcom/tg3.o.old
> >
> > I'm not sure why gcc doesn't do the optimization
> > and code generation the same way.
>
> Out of curiosity I looked at the assembler difference on sparc
> and one thing stood out.
>
> You're changing how the values are evaluated, specifically you
> now are forcing the compiler to work with unsigned ID numbers
> whereas before it was working with signed values.
>
> So, looking at one example, the ASIC revision test in __tg3_set_mac_addr():
>
> if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
> GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
> ...
> }
>
>
> The compiler previously turned the two tests into one:
>
> asic_id -= 1;
> if (asic_id <= 1) {
> ...
> }
>
> But this construct isn't valid for unsigned quantities, so now with
> your patch this expands to two tests:
>
> if (asic_id == 1 ||
> asic_id == 2) {
> ...
> }
>
> The assembler is hard to compare manually, because the inlining
> changes how hard registers are allocated, and issues like the above
> will change all of the branch and file offsets as well. :-/
Well maybe.
If the inlines return int instead of u32, x86 objects
do change trivially (using 2 jg vs ja) , but the size
is unchanged from u32 to int (still bigger).
Perhaps the gcc optimizer could be improved.
next prev parent reply other threads:[~2013-02-11 1:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 23:44 [RFC PATCH] tg3: Convert chip type macros to inline functions Joe Perches
2013-02-07 0:41 ` Michael Chan
2013-02-07 1:05 ` Joe Perches
2013-02-11 0:39 ` David Miller
2013-02-11 1:34 ` Joe Perches [this message]
2013-02-12 1:43 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360546445.2028.8.camel@joe-AO722 \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=hauke@hauke-m.de \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=nsujir@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).