<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109075>109075</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] -Wnan-infinity-disabled is annoying in SIMD code
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Myriachan
</td>
</tr>
</table>
<pre>
The `-Wnan-infinity-disabled` warning added in Clang 18 is annoying when working with SIMD. The kinds of programs that use SIMD code often enable `-ffast-math` for the same reason SIMD is being used in the first place. The warning being enabled by default interferes with libraries. libc++ itself would trigger the warning in `#include <limits>` if Clang weren't suppressing warnings in system headers.
Example of SIMD code that trips up the warning (stripped from the original):
```
#include <immintrin.h>
#define FLOAT_TRUE_MASK (-__builtin_nanf("0x3FFFFF"))
__m128 TestFunction(__m128 v)
{
return _mm_and_ps(v, _mm_setr_ps(FLOAT_TRUE_MASK, 0.0f, FLOAT_TRUE_MASK, 0.0f));
}
```
Yes, it's undefined behavior, but it's also a common thing to do in SIMD code. This isn't a bug, just a coding annoyance.
By the way, it's nice that Clang sees through the masking and just does `vxorps` + `vblendps`. It recognized `0xFFFFFFFF` despite coming from floating-point.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VFuPqzYQ_jXOyygITC7kgYfNyUY6aleVeraq-oQMHmDOGht5TLLpr68M2Z5s1YMQF8_tm8_fWDFTZxFLsT2K7WmlptA7X77cPKmmV3ZVO30rX3sEsUvXf1pl12RbshRua02saoNa7FK4Km_JdqC0Rg1k4YtRtoOsAGJQ1rpbtF57tHB1_m3-odDDt68vpwQgFngjqxlcC6N3nVcDQ-hVgIlx9oLGaQTXBrSANhaeIbWt4rAeVOgjjNZ5CD0CqwHBo2Jnl2BiqDFWnXjBF71a8hxgNKrBO4aPNhbfpYyG-gYaWzWZAGQD-hY98oLfUO2VJ-QE4ncj5FHII1BgNC1c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