[cfe-dev] Behavior of -mcpu

David Greene via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 1 08:24:16 PST 2019


Stefan Teleman <stefan.teleman at gmail.com> writes:

> On Thu, Feb 28, 2019 at 3:42 PM David Greene <dag at cray.com> wrote:
>
>>
>> This is problematic for users.  If clang interprets command-line flags
>> differently based on subtarget, how are users to know what to pass to
>> clang to get, say, the best performance, or best code size, or whatever?
>
> Yes, clang interprets -mcpu= | -march= | -mtune= differently based on
> subtarget. So does GCC. This has been the case for many years.

Ok, but is that the user experience we want?

> For example, on X86_64, both clang and GCC complain if you pass -mcpu=
> on compile-line. On AArch64 or SPARC, neither of them do.

I did not realize gcc has the same behavior, so thank you for clarifying
that.  I understand the desire to be gcc-compatible.

> AArch64 doesn't have the same diversity of sub-arch'es and
> micro-arch'es and micro-tuning that X86_64 does.

Not yet.

> So, fiddling with -mtune= and -march= on AArch64 is probably not as
> useful as it is on X86_64. On AArch64, -mcpu= usually is
> sufficient. You will get the most of what that particular CPU can do
> by default.

It used to be the case that in gcc -mcpu was a shorthand for
-march/-mtune, such that common combinations (broadwell/avx2 for
example) were easy to use.  It's unfortunate the gcc developers
abandoned that idea.

What is the rationale for the behavior of --target/-mcpu/-march/-mtune
in clang?  It would be helpful to have a better idea why things are the
way they are.

                              -David



More information about the cfe-dev mailing list