* [PATCH] of_mdio: merge branch tails in of_phy_register_fixed_link()
@ 2017-08-12 21:03 Sergei Shtylyov
2017-08-14 3:09 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2017-08-12 21:03 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Rob Herring, Frank Rowand, netdev,
devicetree
Cc: Sergei Shtylyov
[-- Attachment #1: of_mdio-merge-branch-tails-in-of_phy_register_fixed_link.patch --]
[-- Type: text/plain, Size: 2224 bytes --]
Looks like gcc isn't always able to figure out that 3 *if* branches in
of_phy_register_fixed_link() calling fixed_phy_register() at their ends
are similar enough and thus can be merged. The "manual" merge saves 40
bytes of the object code (AArch64 gcc 4.8.5), and still saves 12 bytes
even if gcc was able to merge the branch tails (ARM gcc 4.8.5)...
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against DaveM's 'net-next' repo.
drivers/of/of_mdio.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
Index: net-next/drivers/of/of_mdio.c
===================================================================
--- net-next.orig/drivers/of/of_mdio.c
+++ net-next/drivers/of/of_mdio.c
@@ -422,16 +422,13 @@ int of_phy_register_fixed_link(struct de
struct fixed_phy_status status = {};
struct device_node *fixed_link_node;
u32 fixed_link_prop[5];
- struct phy_device *phy;
const char *managed;
- int link_gpio;
+ int link_gpio = -1;
- if (of_property_read_string(np, "managed", &managed) == 0) {
- if (strcmp(managed, "in-band-status") == 0) {
- /* status is zeroed, namely its .link member */
- phy = fixed_phy_register(PHY_POLL, &status, -1, np);
- return PTR_ERR_OR_ZERO(phy);
- }
+ if (of_property_read_string(np, "managed", &managed) == 0 &&
+ strcmp(managed, "in-band-status") == 0) {
+ /* status is zeroed, namely its .link member */
+ goto register_phy;
}
/* New binding */
@@ -454,8 +451,7 @@ int of_phy_register_fixed_link(struct de
if (link_gpio == -EPROBE_DEFER)
return -EPROBE_DEFER;
- phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np);
- return PTR_ERR_OR_ZERO(phy);
+ goto register_phy;
}
/* Old binding */
@@ -466,11 +462,14 @@ int of_phy_register_fixed_link(struct de
status.speed = fixed_link_prop[2];
status.pause = fixed_link_prop[3];
status.asym_pause = fixed_link_prop[4];
- phy = fixed_phy_register(PHY_POLL, &status, -1, np);
- return PTR_ERR_OR_ZERO(phy);
+ goto register_phy;
}
return -ENODEV;
+
+register_phy:
+ return PTR_ERR_OR_ZERO(fixed_phy_register(PHY_POLL, &status, link_gpio,
+ np));
}
EXPORT_SYMBOL(of_phy_register_fixed_link);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] of_mdio: merge branch tails in of_phy_register_fixed_link()
2017-08-12 21:03 [PATCH] of_mdio: merge branch tails in of_phy_register_fixed_link() Sergei Shtylyov
@ 2017-08-14 3:09 ` David Miller
[not found] ` <20170813.200908.1426365653542179792.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2017-08-14 3:09 UTC (permalink / raw)
To: sergei.shtylyov
Cc: andrew, f.fainelli, robh+dt, frowand.list, netdev, devicetree
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Sun, 13 Aug 2017 00:03:06 +0300
> Looks like gcc isn't always able to figure out that 3 *if* branches in
> of_phy_register_fixed_link() calling fixed_phy_register() at their ends
> are similar enough and thus can be merged. The "manual" merge saves 40
> bytes of the object code (AArch64 gcc 4.8.5), and still saves 12 bytes
> even if gcc was able to merge the branch tails (ARM gcc 4.8.5)...
>
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Applied, but if two instances of the "same" compiler just with
different targets changes the optimization, it could be because of a
tradeoff which is specific to parameters expressed in that target's
backend.
So in the future we should probably back away from trying to "help"
the compiler in this way.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-15 11:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-12 21:03 [PATCH] of_mdio: merge branch tails in of_phy_register_fixed_link() Sergei Shtylyov
2017-08-14 3:09 ` David Miller
[not found] ` <20170813.200908.1426365653542179792.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2017-08-15 11:18 ` David Laight
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).