<div dir="ltr">According to gcc's documentation, -march implies -mtune for x86. Which matches what clang does without having -mtune. Their documentation also says -mcpu is a depcrated synonym for -mtune. So I'm not sure that -mcpu ever did -march and -mtune together on gcc at least for x86<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br></div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 1, 2019 at 8:27 AM David Greene via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Kristof Beyls <<a href="mailto:Kristof.Beyls@arm.com" target="_blank">Kristof.Beyls@arm.com</a>> writes:<br>
<br>
> Hi David, <br>
><br>
> I thought that mtune just wasn’t supported for any target in clang,<br>
> but I may be wrong.<br>
> FWIW, the following thread discusses what would be needed to implement<br>
> support for mtune:<br>
> <a href="http://lists.llvm.org/pipermail/llvm-dev/2017-October/118344.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2017-October/118344.html</a><br>
> AFAIK, so far nobody has worked on implementing that proposal.<br>
<br>
Now I'm (more) confused.  If -mtune doesn't work and -mcpu isn't<br>
supported for x86-64 (I get a warning about an unused option) how do<br>
users compile for a target like skylake-avx512 and have the optimizer<br>
tune for it?<br>
<br>
                            -David<br>
<br>
>     On 28 Feb 2019, at 21:42, David Greene via cfe-dev<br>
>     <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
>     <br>
>     <br>
>     Stefan Teleman <<a href="mailto:stefan.teleman@gmail.com" target="_blank">stefan.teleman@gmail.com</a>> writes:<br>
>     <br>
>         On Thu, Feb 28, 2019 at 2:09 PM David Greene via cfe-dev<br>
>         <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
>         <br>
>         <br>
>             Interesting. I am observing different behavior between -<br>
>             mcpu= and<br>
>             -march= -mtune= with aarch64-unknown-linux-gnu:<br>
><br>
>         We never supported -mtune=thunderx2t99.<br>
>         <br>
>         -mcpu=thunderx2t99<br>
>         -march=armv8.1-a+lse<br>
><br>
>     This is problematic for users. If clang interprets command-line<br>
>     flags<br>
>     differently based on subtarget, how are users to know what to pass<br>
>     to<br>
>     clang to get, say, the best performance, or best code size, or<br>
>     whatever?<br>
>     <br>
>     Users don't expect to have to set up their build systems to pass<br>
>     different -mcpu/-march/-mtune flags based on what they are<br>
>     targeting.<br>
>     They want to do something like this and be done with it:<br>
>     <br>
>     TARGET=$(call get_triple)<br>
>     ARCH=$(call get_arch)<br>
>     TUNE=$(call get_tune)<br>
>     <br>
>     CFLAGS += --target ${TARGET} -march=${ARCH) -mtune=${TUNE}<br>
>     <br>
>     They could, but probably won't be happy to, do:<br>
>     <br>
>     ifeq (TARGET,aarch64-unknown-linux-gnu)<br>
>     ifeq (TUNE,thunderx2t99)<br>
>     # -mtune unsupported<br>
>     CFLAGS += -mcpu=${TUNE}<br>
>     else ifeq (TUNE,anothertarget)<br>
>     # -mcpu unsupported<br>
>     CFLAGS += -march=${ARCH} -mtune=${TUNE}<br>
>     else ifeq (TUNE,thirdtarget)<br>
>     CFLAGS += -mtune=${TUNE}<br>
>     endif<br>
>     else ifeq(TARGET,x86_64-unknown-linux-gnu)<br>
>     ifeq (TUNE,skylake-avx512)<br>
>     # -mtune unsupported<br>
>     CFLAGS += -mcpu=${TUNE}<br>
>     else ifeq (TUNE,broadwell)<br>
>     # -mcpu unsupported<br>
>     CFLAGS += -march=${ARCH} -mtune=${TUNE}<br>
>     endif<br>
>     else ifeq(TARGET,third-target-triple)<br>
>     # -mcpu and -mtune unsupported<br>
>     CFLAGS += -march=${ARCH}<br>
>     endif<br>
>     <br>
>     It's hard enough for users to support building for multiple<br>
>     subtargets<br>
>     without having to deal with basic compiler behavior differences<br>
>     per<br>
>     subtarget.<br>
>     <br>
>     Perhaps there is some capability of clang I'm not understanding.<br>
>     What's<br>
>     the expected/canonical way to tune compilation for a subtarget?<br>
>     <br>
>     -David<br>
>     _______________________________________________<br>
>     cfe-dev mailing list<br>
>     <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>     <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
>     <br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>