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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Add combine for fcmp sqrt(x),C --> fcmp x,C*C
        </td>
    </tr>

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

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

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

<pre>
    A patch to do this was proposed here:
https://reviews.llvm.org/D126190

It's a good fold (as mentioned in the review comments other compilers might already have this optimization).

But it requires potentially non-obvious pre-conditions to decide when it is valid. For some constants/predicates, we don't need any fast-math. Other patterns will require loose math on the sqrt. Some patterns are already simplified. And some patterns should be disallowed because we can't compute the squared value without overflow/underflow. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxVU81ymzAQfhq47JjBsrHDgYPj1DM59dAnENJiNiMkoh877tN3BUnazngwK62-Py2904_uBLOMaoToQDuIIwW4ywCzd7MLqGFEj8XuVNQvRX0aY5xDrsSFfx5vhPdQGXObKuevvPSyFYdtW6_d6_M1FuIYQMLVOQ2DMxoK8cQUE9pIzjIHWSZGWPFAuSlvBXC86HM5k0HPB-g6RpDGo9QPGOUNV71ujjTRb5nRCtFW_7I_pwgUGfo9kUf25WKmlcY8wDq7cf2NXMp-caOc1ZRBwpIGKtII9xFtRmCemzSkK7g4D8FNyMpsiJKVsnE-r0nJiFyc4Y4cJms5RrDIBqV9wCBD3EwyjhX8XIxx7hE9k93JmC-FYBzHDrkP3BpLePexgl-Z8fuI5M6vIAJNs6GBkLWdrF61fXeG0SWOvGdFFNi2u2OulExMwzqVXHXmmFPET8bEBDobTtxEkTEiuBv6gc-z22T1-l5BqbudbnetLCNFg13RPL9yLGc39WSxaF7gpHVGzyVfv4dBTfNiisfgg--LAzvDZlPsfqxbH3mhEKdzmbzp_h-5K2tJfcVwXOS5-_zb8Ly-oWLIC4WQ8i1cmqbdPpVj16hD24vtU3OUct-iGEQ77A91q9SgWr3rSyN7NCErL4SwPIELBL-z-pI6UQtRH-rjtqn39aHSst8OQuj2cJSIsi_2NU6SzPdnUPpukdSna-BNQyH-_UZKGQJdeSgWOsaXidP1nXeRh8fnCS8X-m6R_wdekDy0">