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

    <tr>
        <th>Summary</th>
        <td>
            [clang++][precision] Cannot use float sqrt with cmath
        </td>
    </tr>

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

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

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

<pre>
    hey guys, I found a confusing case, can anyone explain it?

Case 1 with camth :
```c++
#include <cmath>
float test(float a)
{
    return a + sqrt(a);
}
```

With the command  `clang++ -O3 -ffast-math -S`, we get 

```asm
test(float):
        fcvt    d0, s0
        fsqrt   d1, d0
 fadd    d0, d1, d0
        fcvt    s0, d0
        ret
```


But Case 2 with math.h

```c++
#include <math.h>
float test(float a)
{
 return a + sqrt(a);
}
```

With the same command  `clang++ -O3 -ffast-math -S`, we get 

```asm
test(float):
        fsqrt   s1, s0
 fadd    s0, s1, s0
        ret
```

I'm not familiar with the difference between math.h and cmath. Can anyone figure me out?

And can we just use float sqrt even with cmath ?


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VE2P2jwQ_jWTywjkOEDIIYcAL9Ke3kMPPTv2JPFuYtPYhvLvKyfpgnbVqlKlIksWPDPj5wNbOKdbQ1TC9gDbUyKC7-xY3jr7Rm-U1Fbdy47u2Ia7A37EF2xsMAoFSmua4LRpUQpHEZPCoDB3awjp-6UX2qD2kJ2BVcCqo3CEKd6071CKwXcIWfwddmxeEvghLlYBz7SRfVCEkB3lIHwH2X_Aqqa3wqMn54Hv5y8CeBFb8tiIiDiSD6NBgcAP6L6NsXQqyqbR-en5zJna18jJd4TSDoMwCjHS6YVpZ0q4-j_DVdMI51eRDK6-xF5-xBthSx7nMe9ThRuAVc80p_OrhWH8NPLq466mMY49Q5F0hNIIqQlqhFKP8mfkwzzHPkEj-c-SgVWH4HEKhc-hRGXr7oOUX4WyFP9ZKn8TiRPDP81lMd-lj1x-mj97-4z8zuEX4PmAxnpsxKB7LcbZ5ihK6aahkYwkrMnfiMziPkaV0x9-jcfHdWp0G0bCgdCGx42qYq0wUexrcB6DI5ztn0TQlcxy3SZz3vsSVWaqyAqRUJnmWbbJWcrTpCuZrLM8zcWOFK83fMf2DSuU3G_q3b5gaZHokjO-STnbsZzvN-l6Xygq8nrHuFBpwQk2jAah-3XfX4e1HdtEOxeoTNN9ke2SXtTUu-mt4XwJksdnZyxjw6oOrYMN67Xz7jHCa99PD9RT9LA9wfZwGUlqp62B7Sn6Fd3-4MLDgCSMfdl5f3Excn4Gfm6170K9lnYAfo7nLdvqMtpXkh74eeLvgJ8XCdeS_wgAAP__XByAuQ">