From: "George Spelvin" <linux@horizon.com>
To: geert@linux-m68k.org, gerg@linux-m68k.org,
linux-m68k@lists.linux-m68k.org, linux@horizon.com
Subject: Re: [RFC PATCH 2/2] arch/m68k: Add CONFIG_CPU_HAS_NO_MULDIV32
Date: 12 May 2016 16:31:16 -0400 [thread overview]
Message-ID: <20160512203116.8654.qmail@ns.horizon.com> (raw)
In-Reply-To: <57347D52.2060801@linux-m68k.org>
> Did you intend to no longer compile any of mulsi3.o, etc, for
> ColdFire targets?
>
> CPU_HAS_NO_MULDIV64 is selected by both M68000 and ColdFire, so
> those functions used to be compiled. But with this change on
> only M68000 will compile them.
Yes, that's exactly the point. ColdFire doesn't need or use them.
This was baiscally my answer to "why is there a ColdFire path
in __mulsi3"?
> When compiling with m5200 gcc will generate calls to divsi3,
> udivsi3, modsi3 and umodsi3. (As far as I can tell we never need
> mulsi3 for ColdFire). So linking will fail with this patch as-is
> in that m5200 case.
Ah! I missed that on my testing. Yes, indeed, there is *one* ColdFire
that needs the divides. And -mcpu=5206 is a supported option.
I had tested with
m68k-linux-gnu-gcc-6 -march=isaa -fomit-frame-pointer -S mul.c
unsigned mul(unsigned x, unsigned y) { return x * y; }
unsigned div(unsigned x, unsigned y) { return x / y; }
unsigned rem(unsigned x, unsigned y) { return x % y; }
int sdiv(int x, int y) { return x / y; }
int srem(int x, int y) { return x % y; }
But yes, -m5206 isn't the same as "-march=isaa -mtune=5200"; the very
first is "ISA A minus" and doesn't have the *divides*.
Now that you point it out, I also see the -m5200 fallback in the Makefile.
Grumble, that just got more complicated. It's easy enough to split
the option into CPU_HAS_NO_MUL32 and CPU_HAS_NO_DIV32, but the answer
depends on the GCC version, not just the config settings.
Options include:
- Punt on the divide part entirely, and just always compile divides like now.
It's just a tiny bit of code space.
- (falsely) set CPU_HAS_NO_DIV32 for those CPUs always.
The problem is, some future code might make optimization decisions
based on that (e.g. using binary vs. Euclidean GCD algorithms),
and for the 99% of people using a modern compiler, it'll be wrong.
- Do some post-Kconfig Makefile magic to detect the situation.
How ugly is this:
+lib-$(CONFIG_CPU_HAS_NO_MUL32) += mulsi3.o
+lib-$(CONFIG_CPU_HAS_NO_DIV32) += divsi3.o udivsi3.o modsi3.o umodsi3.o
+
+# Old GCC versions fall back to -m5200 compilation, generating these calls
+# even though the CPU doesn't actually need it. See arch/m68k/Makefile.
+
+ifeq ($(cpuflags-y),-m5200)
+lib-y += divsi3.o udivsi3.o modsi3.o umodsi3.o
+endif
next prev parent reply other threads:[~2016-05-12 20:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 10:25 [RFC PATCH 2/2] arch/m68k: Add CONFIG_CPU_HAS_NO_MULDIV32 George Spelvin
2016-05-12 12:55 ` Greg Ungerer
2016-05-12 20:31 ` George Spelvin [this message]
2016-05-13 1:02 ` Greg Ungerer
2016-05-13 3:28 ` Finn Thain
2016-05-13 2:39 ` George Spelvin
2016-05-13 4:01 ` Finn Thain
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=20160512203116.8654.qmail@ns.horizon.com \
--to=linux@horizon.com \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=linux-m68k@lists.linux-m68k.org \
/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