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

    <tr>
        <th>Summary</th>
        <td>
            [DAG] Failure to fold freeze(bitcast(x)) -> bitcast(freeze(x))
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:codegen
      </td>
    </tr>

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

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

<pre>
    https://alive2.llvm.org/ce/z/ab6oTs
```
define <8 x i1> @src(i8 %x) {
%0:
  %a = bitcast i8 %x to <8 x i1>
  %r = freeze <8 x i1> %a
  ret <8 x i1> %r
}
=>
define <8 x i1> @tgt(i8 %x) {
%0:
  %a = freeze i8 %x
  %r = bitcast i8 %a to <8 x i1>
  ret <8 x i1> %r
}
Transformation seems to be correct!
```
Moving the freeze out of the way in the DAG (like we do for IR) allows legalization to drastically improve the x86 codegen
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU9tunDAQ_RrzYmWFzf2Bh03pVlXVlzQ_YGAAtwZHttls9us7dtlNs22kVlgwnvGcOWc8tLp_qSfnnixJ9oQfcAklj8B3Sh3nnTYjejrA19mH2lw_WhI3JN6TPN5W2PYwyAUoST6U9EQlI8lHStLYmo7wUpaU8OxEeEVJcb_l8yz2NcOG-rjA7Ia20nXCOrrlUKffgP523oTzgwE43xZGsMtBA-6PoNkoFM1mJM0V-h0hbnT_KWQjdkm55f1Wp3hP57_QfzRisYM2s3BSL9QCzNbjtUA7bQx0SJ399da-6qNcRuomuNDVq6N6CJ5n8ULlEsxm_wkLl0r-QDfQXlMsRz8_-EYIpfSzpQpGnJzzLwpYvDeoTnYYRZT5yegjBKhTmSOrHkZYor5O-iqpROSkU1CT7B4LkayhByHVasDjDFr1GzlksHUNLX8Jvvydb8qr-3pyi0erUTcDPko3re2u0zNu_Jhvnzsk-T006yCtXcGikaUVY9FUCxGnfVrmBQB0A0vaPMnTfijyaiiKkmWREi0o6yUQzgNost9kogM1RbLmMedxyvBJM8Z3ScViGLKCZ1mespLhlMGMwq-_XmTqwKtdR4tBJa2zr0FhrRwXCG3z-GJ1kzb1w5dvctZLFCTUgf9P0-0eZA">