Skip to content

Commit

Permalink
[Headers][X86] Add specific results to comparisons (#83316)
Browse files Browse the repository at this point in the history
Some comparison intrinsics were described as returning the "result" without
specifying how. The "cmp" intrinsics return zero or all 1's in the
corresponding elements of a returned vector; the "com" intrinsics return
an integer 0 or 1.

Also removed some redundant information.
  • Loading branch information
pogo59 authored Mar 11, 2024
1 parent 2a3f27c commit 725a052
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 143 deletions.
114 changes: 54 additions & 60 deletions clang/lib/Headers/emmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,9 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_xor_pd(__m128d __a,
}

/// Compares each of the corresponding double-precision values of the
/// 128-bit vectors of [2 x double] for equality. Each comparison yields 0x0
/// for false, 0xFFFFFFFFFFFFFFFF for true.
/// 128-bit vectors of [2 x double] for equality.
///
/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -429,8 +430,9 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpeq_pd(__m128d __a,

/// Compares each of the corresponding double-precision values of the
/// 128-bit vectors of [2 x double] to determine if the values in the first
/// operand are less than those in the second operand. Each comparison
/// yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
/// operand are less than those in the second operand.
///
/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand Down Expand Up @@ -949,8 +951,8 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnge_sd(__m128d __a,
/// Compares the lower double-precision floating-point values in each of
/// the two 128-bit floating-point vectors of [2 x double] for equality.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -962,8 +964,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnge_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comieq_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdeq((__v2df)__a, (__v2df)__b);
Expand All @@ -974,8 +975,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comieq_sd(__m128d __a,
/// the value in the first parameter is less than the corresponding value in
/// the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -987,8 +988,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comieq_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comilt_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdlt((__v2df)__a, (__v2df)__b);
Expand All @@ -999,8 +999,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comilt_sd(__m128d __a,
/// the value in the first parameter is less than or equal to the
/// corresponding value in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1012,8 +1012,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comilt_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comile_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdle((__v2df)__a, (__v2df)__b);
Expand All @@ -1024,8 +1023,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comile_sd(__m128d __a,
/// the value in the first parameter is greater than the corresponding value
/// in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1037,8 +1036,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comile_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comigt_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdgt((__v2df)__a, (__v2df)__b);
Expand All @@ -1049,8 +1047,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comigt_sd(__m128d __a,
/// the value in the first parameter is greater than or equal to the
/// corresponding value in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1062,8 +1060,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comigt_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comige_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdge((__v2df)__a, (__v2df)__b);
Expand All @@ -1074,7 +1071,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comige_sd(__m128d __a,
/// the value in the first parameter is unequal to the corresponding value in
/// the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 1 is returned.
///
/// \headerfile <x86intrin.h>
Expand All @@ -1087,18 +1084,17 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comige_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 1 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_comineq_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_comisdneq((__v2df)__a, (__v2df)__b);
}

/// Compares the lower double-precision floating-point values in each of
/// the two 128-bit floating-point vectors of [2 x double] for equality. The
/// comparison yields 0 for false, 1 for true.
/// the two 128-bit floating-point vectors of [2 x double] for equality.
///
/// If either of the two lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1110,8 +1106,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_comineq_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomieq_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdeq((__v2df)__a, (__v2df)__b);
Expand All @@ -1122,8 +1117,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomieq_sd(__m128d __a,
/// the value in the first parameter is less than the corresponding value in
/// the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two lower
/// double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1135,8 +1130,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomieq_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomilt_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdlt((__v2df)__a, (__v2df)__b);
Expand All @@ -1147,8 +1141,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomilt_sd(__m128d __a,
/// the value in the first parameter is less than or equal to the
/// corresponding value in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two lower
/// double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1160,8 +1154,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomilt_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomile_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdle((__v2df)__a, (__v2df)__b);
Expand All @@ -1172,8 +1165,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomile_sd(__m128d __a,
/// the value in the first parameter is greater than the corresponding value
/// in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two lower
/// double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1185,8 +1178,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomile_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomigt_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdgt((__v2df)__a, (__v2df)__b);
Expand All @@ -1197,8 +1189,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomigt_sd(__m128d __a,
/// the value in the first parameter is greater than or equal to the
/// corresponding value in the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, returns 0.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1210,8 +1202,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomigt_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison results. If either of the two
/// lower double-precision values is NaN, 0 is returned.
/// \returns An integer containing the comparison results.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomige_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdge((__v2df)__a, (__v2df)__b);
Expand All @@ -1222,8 +1213,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomige_sd(__m128d __a,
/// the value in the first parameter is unequal to the corresponding value in
/// the second parameter.
///
/// The comparison yields 0 for false, 1 for true. If either of the two lower
/// double-precision values is NaN, 1 is returned.
/// The comparison returns 0 for false, 1 for true. If either of the two
/// lower double-precision values is NaN, 1 is returned.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -1235,8 +1226,7 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomige_sd(__m128d __a,
/// \param __b
/// A 128-bit vector of [2 x double]. The lower double-precision value is
/// compared to the lower double-precision value of \a __a.
/// \returns An integer containing the comparison result. If either of the two
/// lower double-precision values is NaN, 1 is returned.
/// \returns An integer containing the comparison result.
static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomineq_sd(__m128d __a,
__m128d __b) {
return __builtin_ia32_ucomisdneq((__v2df)__a, (__v2df)__b);
Expand Down Expand Up @@ -3023,8 +3013,9 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi64(__m128i __a,
}

/// Compares each of the corresponding 8-bit values of the 128-bit
/// integer vectors for equality. Each comparison yields 0x0 for false, 0xFF
/// for true.
/// integer vectors for equality.
///
/// Each comparison yields 0x0 for false, 0xFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -3041,8 +3032,9 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a,
}

/// Compares each of the corresponding 16-bit values of the 128-bit
/// integer vectors for equality. Each comparison yields 0x0 for false,
/// 0xFFFF for true.
/// integer vectors for equality.
///
/// Each comparison yields 0x0 for false, 0xFFFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -3059,8 +3051,9 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a,
}

/// Compares each of the corresponding 32-bit values of the 128-bit
/// integer vectors for equality. Each comparison yields 0x0 for false,
/// 0xFFFFFFFF for true.
/// integer vectors for equality.
///
/// Each comparison yields 0x0 for false, 0xFFFFFFFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand All @@ -3078,8 +3071,9 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a,

/// Compares each of the corresponding signed 8-bit values of the 128-bit
/// integer vectors to determine if the values in the first operand are
/// greater than those in the second operand. Each comparison yields 0x0 for
/// false, 0xFF for true.
/// greater than those in the second operand.
///
/// Each comparison yields 0x0 for false, 0xFF for true.
///
/// \headerfile <x86intrin.h>
///
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Headers/smmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,8 @@ static __inline__ int __DEFAULT_FN_ATTRS _mm_testnzc_si128(__m128i __M,
/// Compares each of the corresponding 64-bit values of the 128-bit
/// integer vectors for equality.
///
/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the <c> VPCMPEQQ / PCMPEQQ </c> instruction.
Expand Down Expand Up @@ -2301,6 +2303,8 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_minpos_epu16(__m128i __V) {
/// integer vectors to determine if the values in the first operand are
/// greater than those in the second operand.
///
/// Each comparison yields 0x0 for false, 0xFFFFFFFFFFFFFFFF for true.
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic corresponds to the <c> VPCMPGTQ / PCMPGTQ </c> instruction.
Expand Down
Loading

0 comments on commit 725a052

Please sign in to comment.