<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-IE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Thanks Eric,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>After the original reply to my query I had a good look at the GCC documentation for these options, and what I discovered is that “there is no consensus” in GCC.  Basically, saying do what GCC does was a non-answer as it clarified nothing.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>X86 has deprecated ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mcpu</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ in favour of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mtune</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, and it uses ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mtune</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ to mean that the scheduling, etc. should be biased in favour of more performant code for the processor identified by ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mtune</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, but that the code is still 100% functional on all other processors in the family identified by ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-march</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>MIPS and ARM seem to have a very different notion of what they mean, and at the end of my examination of these options, I came to the conclusion that there is no common convention for usage and it all seems very haphazard.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>With the processor that I am targeting, the notion of tuning schedules for a particular variant is meaningless, because the schedule is critical in the absence of interlocked instruction execution (and VLIW).  This effectively means that ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mtune</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ is not appropriate to my platform and leaves me with the toss-up of ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mcpu</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ versus ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-march</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, and to tell you the truth, I can see little reason to choose one over the other.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>Most of the time, I want to differentiate based on ISA versions.  That is, the code should be generated for one version of the ISA or another, though for the same basic architecture (ISA can vary a lot from version to version).  ARM seems to use ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-march</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ and ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mcpu</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ more or less interchangeably, and uses ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>+</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’ to add features to the value specified.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>The majority of GCC target only use ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mcpu</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’, so I think that in the absence of any real and meaningful best practice, that I will just stick with the triples and ‘</span><span style='font-family:"Courier New";color:black;mso-fareast-language:EN-US'>-mcpu</span><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>’.<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>All the best,<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'>            MartinO<o:p></o:p></span></p><p class=MsoNormal><span style='font-family:"Book Antiqua",serif;color:#943634;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> cfe-dev [mailto:cfe-dev-bounces@lists.llvm.org] <b>On Behalf Of </b>Eric Christopher via cfe-dev<br><b>Sent:</b> 20 March 2018 17:50<br><b>To:</b> Richard Hadsell <hadsell@blueskystudios.com><br><b>Cc:</b> Clang Dev <cfe-dev@lists.llvm.org><br><b>Subject:</b> Re: [cfe-dev] When to use '-mcpu' versus '-march'<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>Hi Richard,<o:p></o:p></p><div><div><p class=MsoNormal>On Tue, Mar 20, 2018 at 9:33 AM Richard Hadsell <<a href="mailto:hadsell@blueskystudios.com">hadsell@blueskystudios.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><p class=MsoNormal style='margin-bottom:12.0pt'>Does clang differ from g++ in this respect?<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It shouldn't, we strive for compatibility here.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><p class=MsoNormal style='margin-bottom:12.0pt'>This is from the man page for g++ 4.8.5 for Intel x86 and x86-64 processors:<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>However, Martin was asking about a non-specific out of tree target and the advice there should still hold.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>-eric<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><p class=MsoNormal style='margin-bottom:12.0pt'>        -march=cpu-type<br>            Generate instructions for the machine type cpu-type.  In contrast to -mtune=cpu-type, which merely tunes the generated code<br>            for the specified cpu-type, -march=cpu-type allows GCC to generate code that may not run at all on processors other than the<br>            one indicated.  Specifying -march=cpu-type implies -mtune=cpu-type.<br>...<br>        -mtune=cpu-type<br>            Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions.<br>            While picking a specific cpu-type schedules things appropriately for that particular chip, the compiler does not generate any<br>            code that cannot run on the default machine type unless you use a -march=cpu-type option.  ...<br>...<br>        -mcpu=cpu-type<br>            A deprecated synonym for -mtune.<br><br><br><br>On 03/20/2018 12:40 AM, Eric Christopher via cfe-dev wrote:<br>> Hi Martin,<br>><br>> Sorry about the delay here, but I've got some advice even though a lot of things aren't solid anywhere.<br>><br>> a) Does this match an out of tree target for gcc? If so, I'd match that.<br>> 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.<br>> c) -mcpu is occastionally used for "-march+-mtune" when -march by itself is generally "this architecture, but generic tuning".<br>><br><br>--<br><br>Dick Hadsell                    <a href="tel:(203)%20992-6320" target="_blank">203-992-6320</a>  Fax: <a href="tel:(203)%20992-6001" target="_blank">203-992-6001</a><br>Reply-to:                       <a href="mailto:hadsell@blueskystudios.com" target="_blank">hadsell@blueskystudios.com</a><br>Blue Sky Studioshttp://<a href="http://www.blueskystudios.com" target="_blank">www.blueskystudios.com</a><br>1 American Lane, Greenwich, CT 06831-2560<o:p></o:p></p></blockquote></div></div></div></body></html>