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

    <tr>
        <th>Summary</th>
        <td>
            Missing optimization for x86 avx intrinsic `_mm256_zeroall()`.
        </td>
    </tr>

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

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

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

<pre>
    [Here is a simple code](https://godbolt.org/)

````c
#include <immintrin.h>

void fn(float *out) {
    _mm256_zeroall();
 register __m256 r0;
    r0 = _mm_setzero_ps();
 _mm256_storeu_ps(out, r0);
}
````

which is compiled into

````
fn:                                     # @fn
 vzeroall
        vxorps  xmm0, xmm0, xmm0
        vmovups ymmword ptr [rdi], ymm0
        vzeroupper
        ret
````

There are both `vzeroall` and `vxorps` instructions in the code, but only one is needed.
In my specific use case (matrix product), I want to initialize multiple registers using vzeroall with `_mm256_zeroall()` to reduce code size and prevent uninitialized variable warnings by setting all register variables as `_mm256_setzero_ps()`.
The missing optimization makes the leading `_mm256_zeroall()` instruction useless.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVMtuKjkQ_RqzKV1k7NA0i14kYdDcxexmj9ztarpm_Gj5wevrR24IIbmZXAthqapcdc7hUCpG2jvEhi1f2HIzUzkNPjQpny6XWev1uST-xIBAERREsqNB6LxGttwwUQ8pjZHJZya2TGz3XrfepLkP-ymwZnzD-PPtu-L3T3cLCUmuM1kjMPlK1pJLgdx8YPKPx6cHTxp6x0TdG68SMPHsc2JiDWz1ci0BANhZK5bV7oLBK2OYqAsC-VYQcE8xYYDdrpRB4O85AAgcmNyUHruIqfTYjfFzj9uEmHzAfM1PQF5Lt4dCttr8SvqR0XGgbiiadt6OZFADueT_T65rpHdMTlB_e5iQwJ54726wD2-S3NmWczj5MEaAk7W8UPhwf6y0_pDHCGdrjz5oGFMAtnwJmiYXvJbE5ydlZB5HDB_jAdP3yvw9FLepgND6NACr-B19xUE5PYUm6CVALqaQu0TeRSAHabjZU7xCmxN4Z87g3eRfh6hRz69zfjqwZ4gjdtRTBzkidCoiMFFblQKdYAxe567YrDT7CUflEiQP5CiRMnRBsNkkKv-IN3NFyJHc_q44HOlK4ktvVrz0C6hzd0UNsXQtJMeAB3QJsnsfp-GgAqnWIBxVcOT2EdozREypzCzj7iZ_q4yg4sP8X6xd8fldd7AUJ_R-TGTpooqqYNW_GCddDSpd0t_Qefg5iqQGY5zPdCP1Wq7VDJtFtarlspJiNRsaiZV8WnZKr9bVolaiVRVXvBIt79q-r-oZNYILySVfLzhfitW868VCcll3a9nVa9TsiaNVZObGHGxZOzOKMWNTLUS9nBnVoonTahPC4RGmJBOibLrQlDc_2ryP7Ikbiim-d0mUDDZ_fSVH7wOc6grU4QTXdRWp-0aS-SwH03zak5SG3M47b5nYlqG368cY_D9YLLedoEYmthOV_wIAAP__U024mw">