Skip to content

Commit 49b5208

Browse files
authored
[X86][Headers] Specify result of NaN comparisons (#85862)
Make sure all float/double comparison intrinsics specify what happens with a NaN input. Update some existing descriptions of comparison results to make them all consistent. Also replace "yields" with "returns" throughout.
1 parent fa6e433 commit 49b5208

File tree

3 files changed

+193
-113
lines changed

3 files changed

+193
-113
lines changed

clang/lib/Headers/avxintrin.h

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b)
207207
/// Compares two 256-bit vectors of [4 x double] and returns the greater
208208
/// of each pair of values.
209209
///
210+
/// If either value in a comparison is NaN, returns the value from \a __b.
211+
///
210212
/// \headerfile <x86intrin.h>
211213
///
212214
/// This intrinsic corresponds to the <c> VMAXPD </c> instruction.
@@ -226,6 +228,8 @@ _mm256_max_pd(__m256d __a, __m256d __b)
226228
/// Compares two 256-bit vectors of [8 x float] and returns the greater
227229
/// of each pair of values.
228230
///
231+
/// If either value in a comparison is NaN, returns the value from \a __b.
232+
///
229233
/// \headerfile <x86intrin.h>
230234
///
231235
/// This intrinsic corresponds to the <c> VMAXPS </c> instruction.
@@ -245,6 +249,8 @@ _mm256_max_ps(__m256 __a, __m256 __b)
245249
/// Compares two 256-bit vectors of [4 x double] and returns the lesser
246250
/// of each pair of values.
247251
///
252+
/// If either value in a comparison is NaN, returns the value from \a __b.
253+
///
248254
/// \headerfile <x86intrin.h>
249255
///
250256
/// This intrinsic corresponds to the <c> VMINPD </c> instruction.
@@ -264,6 +270,8 @@ _mm256_min_pd(__m256d __a, __m256d __b)
264270
/// Compares two 256-bit vectors of [8 x float] and returns the lesser
265271
/// of each pair of values.
266272
///
273+
/// If either value in a comparison is NaN, returns the value from \a __b.
274+
///
267275
/// \headerfile <x86intrin.h>
268276
///
269277
/// This intrinsic corresponds to the <c> VMINPS </c> instruction.
@@ -1604,9 +1612,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
16041612
/// 128-bit vectors of [2 x double], using the operation specified by the
16051613
/// immediate integer operand.
16061614
///
1607-
/// Returns a [2 x double] vector consisting of two doubles corresponding to
1608-
/// the two comparison results: zero if the comparison is false, and all 1's
1609-
/// if the comparison is true.
1615+
/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
1616+
/// If either value in a comparison is NaN, comparisons that are ordered
1617+
/// return false, and comparisons that are unordered return true.
16101618
///
16111619
/// \headerfile <x86intrin.h>
16121620
///
@@ -1663,9 +1671,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
16631671
/// [4 x float], using the operation specified by the immediate integer
16641672
/// operand.
16651673
///
1666-
/// Returns a [4 x float] vector consisting of four floats corresponding to
1667-
/// the four comparison results: zero if the comparison is false, and all 1's
1668-
/// if the comparison is true.
1674+
/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true.
1675+
/// If either value in a comparison is NaN, comparisons that are ordered
1676+
/// return false, and comparisons that are unordered return true.
16691677
///
16701678
/// \headerfile <x86intrin.h>
16711679
///
@@ -1721,9 +1729,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
17211729
/// 256-bit vectors of [4 x double], using the operation specified by the
17221730
/// immediate integer operand.
17231731
///
1724-
/// Returns a [4 x double] vector consisting of four doubles corresponding to
1725-
/// the four comparison results: zero if the comparison is false, and all 1's
1726-
/// if the comparison is true.
1732+
/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
1733+
/// If either value in a comparison is NaN, comparisons that are ordered
1734+
/// return false, and comparisons that are unordered return true.
17271735
///
17281736
/// \headerfile <x86intrin.h>
17291737
///
@@ -1781,9 +1789,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
17811789
/// [8 x float], using the operation specified by the immediate integer
17821790
/// operand.
17831791
///
1784-
/// Returns a [8 x float] vector consisting of eight floats corresponding to
1785-
/// the eight comparison results: zero if the comparison is false, and all
1786-
/// 1's if the comparison is true.
1792+
/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true.
1793+
/// If either value in a comparison is NaN, comparisons that are ordered
1794+
/// return false, and comparisons that are unordered return true.
17871795
///
17881796
/// \headerfile <x86intrin.h>
17891797
///
@@ -1842,8 +1850,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
18421850
/// two 128-bit vectors of [2 x double], using the operation specified by the
18431851
/// immediate integer operand.
18441852
///
1845-
/// If the result is true, all 64 bits of the destination vector are set;
1846-
/// otherwise they are cleared.
1853+
/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
1854+
/// If either value in a comparison is NaN, comparisons that are ordered
1855+
/// return false, and comparisons that are unordered return true.
18471856
///
18481857
/// \headerfile <x86intrin.h>
18491858
///
@@ -1900,8 +1909,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c)
19001909
/// vectors of [4 x float], using the operation specified by the immediate
19011910
/// integer operand.
19021911
///
1903-
/// If the result is true, all 32 bits of the destination vector are set;
1904-
/// otherwise they are cleared.
1912+
/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true.
1913+
/// If either value in a comparison is NaN, comparisons that are ordered
1914+
/// return false, and comparisons that are unordered return true.
19051915
///
19061916
/// \headerfile <x86intrin.h>
19071917
///

0 commit comments

Comments
 (0)