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

    <tr>
        <th>Summary</th>
        <td>
            Implement reciprocal of ldexp optimization
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            missed-optimization,
            floating-point
      </td>
    </tr>

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

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

<pre>
    It should be possible to fold fdiv by known power of 2 to fmul of the inverse, at least for certain value ranges. We already do this for some constants.

Something like
1.0 / ldexp(x, n) -> ldexp(x, -n) should be possible. I believe the hazardous edge case is if n is large, this can trade 1/infinity = 0 for a multiply by a denormal, so we would either need a range check on the inputs or no infinities (or know denormals are zero is enabled)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxkUs1upEwMfJrmYg1iGpgMBw75Mt9IOe9hz4Y24E3TRu1mJpOnX0Gi_dFe2uqSVeWyC1V5DEStqf8z9SXDNU0SW4xKYc46cY_2NYFOsnoHHcEiqtx5giQwiHcwOL5B94C3IPcAi9wpggxg94Z59dsnTQQcbhSVjH0BTOAJNcEgEXqKCTnADf1KEDGMpDl8J0AfCd0DnECaWPdmlZmgl6AJQ9LcFBdTPH--32SmNHEYwfMbfWLHvABjr-AdvS_Gnt839WBsAwdT_v83fNjxf43m8AodeaYb7T4m_MDoZFUgNxL0qASswAOErXqM425yn7nHACmiIzgae-UwcOD0AFNeoNgNIcyrT7z4x7ZDBEdB4ox-Y1CBO8F9H4g4TRQhEDnAzy1BP1H_BhK-1rusSUEiBIEvISYFY88S9-P84lbASPBBUbaBKWDnyRnbZK4tXVM2mFF7PDVF05zrss6m1qJrXN0fK9vXjo6u6BDrrjp19GTxTFXGrS1sWZwLe3yqznWdW-pdhWXdl080lN3JVAXNyD73_jbnEseMVVdqT1VZF5nHjrzuCbR2ZlVyB1kSz_yBiSUYa419MdYOXjBxGA-LcEgbXF-y2G6kh24d1VSFZ036WyZx8tS-zounmUKCSD0vUXrcc7kHAP6Uytbo2ymlRU35bOzV2OvIaVq7vJfZ2OtG_FUOS5Qf1KftsJsZNfa6-_kZAAD__959HU4">