<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87758>87758</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang differences when using commandline options or pragmas to turn on fast-math functionallity
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
karka228
</td>
</tr>
</table>
<pre>
When looking at the output from clang -cc1 for the program below
```
float powf(float x, float y);
float sqrtf(float x);
float f2(float x, int y) {
x = powf(x,y);
x = sqrtf(x);
return x;
}
```
Compiled with:
`$ clang -cc1 foo.c -triple x86_64-linux-gnu -emit-llvm -o - -ffast-math -ffp-contract=fast`
The result of the `-ffast-math` and ` -ffp-contract=fast` options is that both calls to pow and sqrt are annotated with fast math flag `fast` (see LangRef):
```
%2 = call fast float @llvm.pow.f32(float %0, float %conv)
%4 = call fast float @llvm.sqrt.f32(float %3)
```
When instead turning on fast math with `#pragma float_control(precise,off)` like this:
```
float powf(float x, float y);
float sqrtf(float x);
#pragma float_control(push)
#pragma float_control(precise,off)
float f2(float x, int y) {
x = powf(x,y);
x = sqrtf(x);
return x;
}
#pragma float_control(pop)
```
Compiled with:
`$ clang -cc1 foo.c -triple x86_64-linux-gnu -emit-llvm -o -`
The result of the pragma is that only the sqrt call get to be annotated with the fast math flag `fast`:
```
%2 = call float @llvm.pow.f32(float %0, float %conv)
%4 = call fast float @llvm.sqrt.f32(float %3)
```
Why are not `llvm.pow.f32` not annotated with fast math flag `fast` when using `#pragma float_control(precise,off)`?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2P2zYQ_TX0ZSBDpj590CFZw6eeigI9BhQ1ktilSJUcxfa_L0jZazvtbhOgBQIYtESO3sx7nEcK79VgEBtWfGbFYSMWGq1rXoV7FZzXm9Z2l-b3EQ1oa1-VGUAQ0IhgF5oXgt7ZCaQWZoBEyh301sXl2dnBiQla1PbE0gNLP13HMr3-4muvrSCY7alnvF5fzoy_wPp4YXzPss-Pof5PR0-x94DHsJ4_4ymzogGrrtEAZ2DZ4ZY7RD2lu63fEp6fFx3S4gyc79mrwz8yfLHTrDR2cFI0suxBBp4_K2e3EhJyatYI57r8UuaJVmY5J4NZIMFJUaL11wkSCwkkfS88JZOgMTzPibSGnJDEskNYecu_jr-NCA79oglsH3eIlekDBitTEKYLs-_BgZ1JWeNBeaBRELSWRpBCaw9kg44RIegFwiEIYywJujKHgAKx3F6LISS64TJee0T4RZjhV-yjzJ8-aBkAxgse9yYkX4HXrWZ5GhTazva07bN7CzBepPeuYryQ1nwNie6A-YeAgdS3iNkbwDcFrmM0jTKeUHQQeiWYx5oHHaIssRGy2YlhEmvSL1F6qxmvZ4dSeWT8xfZRmDIFrV4RaFT-Y5X-e2N9UObix7sY38_mp3Lt-2Xb-b2d_n-8_a_WvRZ686E1-hLno_ViCw9IwZPt31wYwt514g_67ie03CWePMZSYPVUV5nG6e8-lE7BvosPpv1Ri7LsuNaz6Zqs22d7scFmV-14lla8rDZjs89E30kpZY61bPN9sd-nqagQd1hhgdVGNTzleZqnRVoXOa-2RbWrWlHWWV7KTFZ7lqc4CaW3kaR1w0Z5v2BTV1VRb7RoUfvbne6aEJS0y-CDuMqTv39GijQ2L7FXO9X36NBI9I_8pZ0mYTqtDL7dAdZduzCe_dFU17NtvZL6xcgQKbRWdNksTjcj0RwPLX5k_DgoGpd2K-3E-DFUc_1LZmf_QEmMHyMjz_gxkvorAAD__wXyni8">