<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62098>62098</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang ignores optnone when translating math functions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang,
floating-point
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
andykaylor
</td>
</tr>
</table>
<pre>
When I compile a C file with fast math enabled (using either -ffast-math or -ffp-model=fast, for example) clang does not respect attributes (optnone) or pragmas (float_control(precise, on)) that should locally prevent the substitution of intrinsics for math library calls which set errno. In the case of sqrt, this also leads to the generation of sqrt instructions (such as sqrtsd on x86-based targets) rather than calls to the sqrt function.
Here is an example: https://godbolt.org/z/P35sEbnr5
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcU8uS4zYM_BrqgrJLph62DjpM7Lgyt9xyTEESJDKhSC0BzYz367fI8exW7UUPotGNhlrIbBdP1KvmD9XcCtzFhNijnx7_48OFWAxhevT_GPLwCmNYN-sIEK4wp4d3KwZmZIEVxQB5HBxNoPRlZ-sXICuGIhzmhDlkTMiv22ENEzlV3VJF6SvMIQJ94Lo5UrqD0aFfYArE4INAJN5oFECRaIddiJNI2MQHn_EhwhZxWTEXZhdQ_h2Dlxic0pct0miZkk7wSnepQwwKsAm7m8CFEZ17wBbpjbyAGALeBxYru9jgIcxgvUTr2Y6cZ81mnB0ixgekboZ3Y0cDTAIUow9HePWZaUSmxMDfYrYqxjKg4wCOcGKQkGELeYr4JZfAYD1L3Md0ln3xPhpAzkWeIHj4uLSHAZkmEIwLCSdrEfPaxaB_jvaUyKTz7jPjUZU3Vb58Xv-iSJDG8j-_QvUCRmRjVb0ofVf6voRpCE6OIS5K378rff-7avjPwcemmPpq6qoOC-pP7eVUnc7NpS5Mfx67pqqHktqunOl8Luu2bYhopvZSnU9VYXtd6qqsT_rUVl1dHwmpa2fEQdN06upZ1SWtaN3Rubc1aReWeae-1WV3KRwO5DjHV-scGqW10leldQ6B9cthC9ZLOm5uRewTzWHYF1Z16SwL_yIWK476a46eXXyIxPDMGLynX0AienaZ9TMAX7vkYo-u_21dVsw-HMewKn1PGs_bYYvhPxpF6Xt2wkrfs5kfAQAA__9NBjVA">