<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/98443>98443</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Treat -march=native as -mcpu=native on AArch64 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ktkachov
      </td>
    </tr>
</table>

<pre>
    Generally speaking, -mcpu=native is the recommended option for native AArch64 Linux users for getting the best CPU and architecture-specific performance out of their code.
However, many makefiles out there are geared towards a default x86 environment and use -march=native, which is the recommended option on that target.
To help with aarch64 porting for those users and avoid them having to special-case aarch64, we could treat -march=native as -mcpu=native. That is, select not just the architecture features of the host system, but also select the host CPU through the part number and tune for it in codegen.
This will keep the contract of -march=native while providing a better performance experience for the users and help with porting.
GCC does this since GCC 13 https://gcc.gnu.org/g:dd9e5f4db2debf1429feab7f785962ccef6e0dbd
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlMFy4ygQhp9GvnTZJWFZtg46ZJPy7GEPe8g-QAtagjECFTRy8vZbEGdmJ4etOWEDf_P39yMwRjM7oqE6_VGdXnaYWPsw3PiGUvttN3r1PnwjRwGtfYe4Et6MmyvxDPtFrqk6vjhksxGYCKwJAkm_LOQUKfArG-9g8gEem56egtRdC38Zl94gRQqxLM_EbNxcKowUGZ7__gfQKcAgtWGSnALt40rSTEbCSmHyYUEnCXxi8FNWmgDSKzpU9UtVP_3p77RRyE4XdO-w4I0mYykWBWsKBBgIZsJACtjfMagICIomTJbh7dIBuc0E7xZyXOykSLBfsqkfjecD7tpI_T8EvAPWyMAYZuKHwVcPmuwKd8MaED_ArD4UEBkKax_pAamw2LxR-YgFNG4Fl4fCBO1eYqTPKsUSgfTJKuBAyF9NA8Yv-R3gNTs0MYsjWZIMzjN8T7HQ-iUJmAjzGB_kQfvIEN8j05L1Y2JAG_1noR9bcqysg0-zLpMrBgaXlpFCaZGTo9K7YTCuxDmT-wSmTYS7sRZuRGvRS-84oCw34GuLd20swRr8ZlSGhTASM4Vfbg-9rRQM5Z8fyP8L_Gc8j1geRr49P4PylOM2EaLJ6jzXHEEzr7E6PlXiWonrLOVhdungw5z_VccnpXo6Ta0ahaJxalrRT4TjeTpfTn0npKSpo1qNaqeGo-qPPe5oaM6i7i4nUXc7PfQdjl2PzYnaM536scNTe2xa2fQKp16ddmYQtWjrc9PUl7pru8P5OEk8qwbP7aW-NKJqa1rQ2IO125Kt7UyMiYb-0rbHncWRbCzPgRCO7lAWKyHy6xCGrNmPaY5VW1sTOf6swoYtDa-_d93yJ_H5GOxSsMMXcIZ1Gg_SL5W45hMew34N_jtJrsS1-IqVuH743gbxbwAAAP__AeylDA">