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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] CPU2006/454.calculix 38% slow-down after `Set dead phi inputs to poison in more cases`
        </td>
    </tr>

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

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

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

<pre>
    The regression happened after https://reviews.llvm.org/rGd01aec4c769d50fb92e86decd41d077c94105841 with `Flang` and `-Ofast -march=native` on Icelake server.
Reverting the patch brings performance back.

The whole slow-down is in the loopnest at `e_c3d.f:675`.  There is many reported 4k aliasing events, which I think are caused by extra register spills inside the loop. `llvm-mca` also suggests that the code generated for the loopnest after the patch is much slower, than before the patch.

Files with more information and a reproducer:

[mca_36.gz](https://github.com/llvm/llvm-project/files/12337651/mca_36.gz) - the loopnest assembly and `llvm-mca` report before the patch (rev: c0a36a1)

[mca_37.gz](https://github.com/llvm/llvm-project/files/12337650/mca_37.gz) - the loopnest assembly and `llvm-mca` report before the patch (rev: d01aec4)

[before_icp.llvm.gz](https://github.com/llvm/llvm-project/files/12337649/before_icp.llvm.gz) - LLVM IR for `e_c3d` routine containing the loopnest

[after_icp.llvm.gz](https://github.com/llvm/llvm-project/files/12337648/after_icp.llvm.gz) - LLVM IR arter `opt before_icp.llvm -S -o - --passes=instcombine`


InstCombine reorders instructions in the loop body quite a bit, and it looks like this ends up increasing the register pressure somehow. 
 It does not look like the reordering is the intended behavior of the patch, so can we avoid it?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU1v4zYQ_TX0ZWCDoj4sH3zIxlARYIsWu9teA4ocS1NTpEpS9mZ_fUEpzudeCmQvCiKR4_fevHkjQ6DOIu5Z-YkJYelEignBysNKTrF3fn_-IU-99LRqnX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