<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70533>70533</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[fast-math] Is it more reasonable to check whether the function attribute has the `unsafe-fp-math` flag or whether a single IR has the fast-math attribute?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
erickq
</td>
</tr>
</table>
<pre>
I recently ran into a problem in my work. I added fast-math when compiling a source program. When I did an optimization, I didn't know whether to check the function attribute or the LLVM ir flag.
For example, in the preceding IR, I want to optimize the lvm.fmuladd.f64 intrinsicsic. The `unsafe-fp-math` flag exists in the attribute function. My question is, is this IR wrong? Because fast-math is enabled in the compiler, llvm.fmuladd.f64 must contain fast-related attributes.
![image](https://github.com/llvm/llvm-project/assets/12108571/69381faa-8027-4094-a31c-5d405af7dd2d)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU02PpDYQ_TXmUmpkbD6aA4edjJBa2r2souRc4AKcMTZrm_ROfn2Ee7t78nXIBQ7levXqvVcYgp4tUceqF1a9ZrjHxfmOvB7fvmWDU-_dBTyNZKN5B48WtI0OEDbvBkMraAvrO1ydf8vhAqgUKZgwxNOKcYHrQhZGt27aaDsDQnC7H-nonj2uOfx6PLiA0grQgtuiXvUfGLWzTPx0K1gmmghv1l0PuLiQh-hgXGh8g7gQTLsdjwbAGL0e9kjgfKp8_vzLF9AeJoNzzvgr458-fnvngb7juhk6hmmbmrZjW3WwvXy9cbiijcfIH-woPTO_r_m07gaVyqe6PGTx2gY9Bj3m8PNCwGq-24ATnaYtqcFqnqgAfdchhvvAJ-37Jjl8eYdvO4W0lg6JXYC46ACXr3D1zs5M9vBCI-6BPuitA5DFwZC6o9_EJ39gmL-TXvcQYXQ2orY3FE8GI6knqfBX4UTBqhe94kysemXivMS4BSY_MdEz0c86LvuQj25loj-m_fidNu9-ozEy0WMIFAMTfSEKfq6agom-buW5mBBPZy6aU8nb8oSyGE-VKnmFU6OUUEy0_3QwU51UrWwxo66o23NZy6pusqUTdSXqYRJtUTQkiUbZ4CBEIZUsW86LTHeCC1lwceZS1LzJVSsrLgesypa3VVGwktOK2uRJNOfnTIewU9fwSsrM4EAmpKMRwtIVUpEJcdyQ79LOwz4HVnJzeP1EiTqadG0P01j1CpcAOsLqPIEnDC55-Iz5I_f_HvcFQyr9d-Kcf2AgBG1nQ0eS7o3PAD1Ameyz3ZvufxuclDgMTkr9GQAA__-cCXA0">