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

    <tr>
        <th>Summary</th>
        <td>
            Other patterns where clang is not optimal for powi (with fast-math)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    There have been a few missed-optimization issues with `pow(x, n)` where `n` is an integer. Here, I will provide some other patterns which aren't mentioned in the existing issues.

Test case(1):
https://godbolt.org/z/WGdxTWK6G
```c
#include<math.h>

double f1(double a)
{
   return pow(a, 5) / pow(a, 2);
}

double g1(double a)
{
   return pow(a, 3);
}
```
If we rewrite `/ pow(a, 2)` as ` * pow(a, -2)`, we won't have a problem.

Test case(2):
https://godbolt.org/z/W6nWzhfss
```c
#include<math.h>

double f2(double a, double b)
{
   return pow(a, -2) * pow(b, -2);
}

double g2(double a, double b)
{
   return pow(a * b, -2);
}
```

Related existing issues:
https://github.com/llvm/llvm-project/issues/67216
https://github.com/llvm/llvm-project/issues/69862
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMFu4zYQ_RrqMrBBjWRKPuiwSartoocCRYCcKWkksaVIg6SiNF9fUFKw3iBpuwlg0DMecubxPfpJ79VgiCp2umGnu0TOYbSu-usgnbOLTxrb_V3dj-QIRvlI0BAZkNDTApPynrqDvQQ1qWcZlDWgvJ_Jw6LCCEzwi10Ylk8Mb8EwPDPBYVl7McFNzJQHaUCZQAO5I_xKjuLmb7AoreHi7KPqCLydCGwYycFFhkDOeFhG1Y4gHRmGRYCJTARAHSgDYSSgJ-WDMsMO6cj4HeNftvWefIBWemJYphFXthfGEC4-ZlgzrAfbNVaHo3UDw_qZYf3wtXu6f_hNfN27Cb592j3HTJlWzx2x7HaSYTyOLPvlenJn50YT9CnDco9lBLBtKW62AAAchdkZ2AiUkZMTwzMwrK9_wxX8zcvxuzdGDR8Ylb3d9uW2W_qth4XA0eJUWAV9C5vgIH0sAsMv19XDXo7xQrDYTcb1jckofKNpelc0_CnRhHl4HnvvPysa_sDkLexx8z9ZXa98xUPznYf_kPATg9d5_zrpR1W39Q_SMlD3-k_0HuUqjHNzbO3EsNb68eXrcHH2T2oDw3o_j7UoMBWfbnIuBSZdlXXn7CwTqtKC56eUi1OZjFWT8oJQ5kIWhI3oeJPzhkrkhcjbsueJqpBjzlMueJbyU3nsc8p6SnvZnvOuyAXLOU1S6WMEEF9Sso6uiiIt0kTLhrRfDROx1dIMDDF6p6tWwM08eJZzrXzw3zsEFTRVv782sWiGa49ohcYGWO1UauitixoqYFiudtpLHw7xfTI8J7PT1cf5W-_xTwAAAP__2QW_lQ">