<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54472>54472</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang -march=x86-64 is different from the generic x86-64 tuning
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zmodem
</td>
</tr>
</table>
<pre>
I was wondering why clang seems to prefer `add $1` over `inc` when building Chromium, even though https://github.com/llvm/llvm-project/commit/0b7669f33331b7af157be4de02ab9dcbc2590dc2 made `inc` no longer considered slow in the generic tuning.
It seems it's because we pass `-march=x86-64`. Which is surprising to me, because that sounds generic enough.
Consider:
```
$ cat /tmp/a.cc
bool f(unsigned *i) {
return ++(*i) == 0;
}
$ clang -O2 -S -o - /tmp/a.cc -target x86_64-unknown-linux-gnu
[...]
incl (%rdi)
sete %al
retq
$ clang -O2 -S -o - /tmp/a.cc -target x86_64-unknown-linux-gnu -march=x86-64
[...]
addl $1, (%rdi)
sete %al
retq
```
Is this working as intended?
Adding `-mtune=generic` brings back the `inc` instruction:
```
$ clang -O2 -S -o - /tmp/a.cc -target x86_64-unknown-linux-gnu -march=x86-64 -mtune=generic
[...]
incl (%rdi)
sete %al
retq
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VE1v2zAM_TXKhbBhy3acHHxoGxTYaYcddhxkibG12lKmj6bdrx_luFvTAcOGDTME64ME9fhEvt6q5-4dnIWHszUKnTYDnMdnkJOglUecPQQLJ4dHdMC2hVAKGK9LWoJ9vJxpI9P2PKKBPupJpSh3o7OzjjPjd4CPZAmjjcMIYwgnz6obxu9pDDqMsc-lJb_7aXp8mbKTs59RBtqSbdZpUfTtdrs_VvSVfSuOZdP2WCssuOj3SvaSN_tCSQ6zUPgKl7EwWTMQVmmN15QlKvCTPYNOqBAGNJS5hBANIc9ZcWDFzeX_LqwkJASthx6liB7hjHAS3qdbslk4ObLq8LTbZtuaTnL4OGo5gvbgozs57RMhROOMiY2XGGEUFN1Go_x3CGgSSVcQ7lbQibNXx3TPOi5bXoOkeMRTmE_0F7mUF1Nv7QRHxneRAg0G0wPeaMb3wNrbiwssn8MQnSHr7TJ2392qAw0oWLW6s_ZwBSXdvRRM9p5D9gEyC9k1EsiCcAMGIJI-bessmgdjzyabtIlP2WDiGqm5zfOcNYfXsIDeSU5pXjA1TiVU1x4eA148GjFdmyirL_8aLbx99F-hp5ZZ0VPb0Pv_bRZvHv5Sp9Smo05d7B5SsVFDaxOQWlqx6v61541a2nMpXCp4pBzW4ku90icFoDIX8mFpjR9dpI0PLsqgrfmNSvzH_MJPWP9HubzktVFdpfbVXmyCDhN2a3ZvIBL7Sh9JJtEEOJL4XWnL6nSRmE10U_fHQqi9j-hp0dR1yzdjJ1Aei7It232tlCxbLMSOC1lJXohK7MRmEj1OviOaGOcGSfBSCFoTZRvd8YLzouJlWTS7sszbXSFqUlLOt21T7CWrC5yFnvKEI7du2LhugdTHwZNx0j74H0aSw6QuuFxH8UUkxXfd19kqnDfLzd2C_Bt4cN-I">