[cfe-dev] When to use '-mcpu' versus '-march'
Eric Christopher via cfe-dev
cfe-dev at lists.llvm.org
Tue Mar 20 10:49:42 PDT 2018
Hi Richard,
On Tue, Mar 20, 2018 at 9:33 AM Richard Hadsell <hadsell at blueskystudios.com>
wrote:
> Does clang differ from g++ in this respect?
>
>
It shouldn't, we strive for compatibility here.
> This is from the man page for g++ 4.8.5 for Intel x86 and x86-64
> processors:
>
>
This is because this is for the in-tree x86 target. ARM is different. Mips
is more like what I said. mn10300 is more like what I said. Power is
different again, and in a different way.
However, Martin was asking about a non-specific out of tree target and the
advice there should still hold.
-eric
> -march=cpu-type
> Generate instructions for the machine type cpu-type. In
> contrast to -mtune=cpu-type, which merely tunes the generated code
> for the specified cpu-type, -march=cpu-type allows GCC to
> generate code that may not run at all on processors other than the
> one indicated. Specifying -march=cpu-type implies
> -mtune=cpu-type.
> ...
> -mtune=cpu-type
> Tune to cpu-type everything applicable about the generated
> code, except for the ABI and the set of available instructions.
> While picking a specific cpu-type schedules things
> appropriately for that particular chip, the compiler does not generate any
> code that cannot run on the default machine type unless you
> use a -march=cpu-type option. ...
> ...
> -mcpu=cpu-type
> A deprecated synonym for -mtune.
>
>
>
> On 03/20/2018 12:40 AM, Eric Christopher via cfe-dev wrote:
> > Hi Martin,
> >
> > Sorry about the delay here, but I've got some advice even though a lot
> of things aren't solid anywhere.
> >
> > a) Does this match an out of tree target for gcc? If so, I'd match that.
> > b) Typically -march/-mtune (though the latter isn't supported in llvm at
> the moment, see an earlier post from me to llvm-dev on how to support that)
> are what I'd use for new ports. We used it in a number of new/out of tree
> ports in gcc as well.
> > c) -mcpu is occastionally used for "-march+-mtune" when -march by itself
> is generally "this architecture, but generic tuning".
> >
>
> --
>
> Dick Hadsell 203-992-6320 <(203)%20992-6320> Fax:
> 203-992-6001 <(203)%20992-6001>
> Reply-to: hadsell at blueskystudios.com
> Blue Sky Studioshttp://www.blueskystudios.com
> 1 American Lane, Greenwich, CT 06831-2560
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180320/058bb00b/attachment.html>
More information about the cfe-dev
mailing list