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

    <tr>
        <th>Summary</th>
        <td>
            "ran out of registers" error when compiling x86 AMX-TILE code
        </td>
    </tr>

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

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

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

<pre>
    Reproduced @ OS Windows 11, clang 14.0.5 (the binary from https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.5).

$ clang.exe -c -O2 -mamx-tile -mamx-int8 C:\work\gb\amx_test3.c
error: ran out of registers during register allocation 

The reproducer contains 3 static functions, each using 3 tile variables, and a non-static function that calls those 3 functions.
As it seems, the 3 static functions are inlined into the caller, and the tiles in each function aren't destroyed when they leave the scope, so it breaks on 9th tile as only 8 TMM registers are available. With -fno-inline the issue dissappears.
[amx_test3.zip](https://github.com/llvm/llvm-project/files/8961246/amx_test3.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1vnDAQ_TVwGYHAfCwcOGyTRqrUKFIbqb1VxsyCG7CRbXaz_fUdw26SflwirezxjOfN85thW92dmy84G90tAjsI8gQevsI3qTp9spCmAbsBMXLVQ5rHSVxAwCo3ILRScXOGg9ETDM7NNsj2AbujXy_dsLSx0BMdxvF43SIq8hOFo6PBEblFS6bj_SWuTR9tNQJWx0FyGyT7y8ryjUOMzwiRgOiBQTTx6TlycsSLKZWr4MbTKG5O2jzR1re0UOyHQ-uyWGxwaIw2dA8MV6AXB_oABntpHRoL3WIkvfbqAD6OWnAntYK3nB5JA3PVzYDQynGpLGRgHd0WcFiU8FnWK4hcDLBYD5zByvnIjeTtiGuYqw44KK2iv5LBDdyBIA6WTG2R0l-ALxrtLUgHFnFasXxz_iUB3CBINUpFTSal9HrPA6O5MvAez43w1Mb4hQZlq4DtHHQkpNFnAjkN6OnhGaiXR1yzrdAzejirPafWIH-yQPm1G7Znc38cz1DB4_39G9U9PX7kcvSaxDR_lBAdlI42ziu6tHZB6Gjj84zcXAUIig-vPf4l56C4pSF991Ae5NqNu6ouU5aXZP2JyuqtXNg1WVdnNQ-ddCM2AWP_GyRywzppm1JUeZajH4DnqoT9_ffo8dPnj-TuMFzM2Lyb7qqG51uUaVmGQ9MyrPOq5XlXZmW1K5hos7xLiqysiyrr0pC0xdE2JBdxU3jaBCWbBAtlwxLGkpLRUtRZEqfZgYlil9c7noo6T-ifASdqUOx5xPSxhqZZKbVLbyk40rPta5BbK3uFuJYjfL7Q_JpmmtFMUulwrd2s3H8DIxt9Qg">