[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/pogo59 closed https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. RKSimon wrote: I don't think so either - we don't need to start explaining general fp comparison behaviour, just any x86/sse quirks. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/phoebewang approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -513,7 +526,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpge_pd(__m128d __a, ///operand are ordered with respect to those in the second operand. /// ///A pair of double-precision values are "ordered" with respect to each pogo59 wrote: Done https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/pogo59 updated https://github.com/llvm/llvm-project/pull/85862 >From 5ed257ea248a5868cd3190bd1ad89413a1606370 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Tue, 19 Mar 2024 13:20:14 -0700 Subject: [PATCH 1/2] [X86][Headers] Specify result of NaN comparisons 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. --- clang/lib/Headers/avxintrin.h | 42 ++ clang/lib/Headers/emmintrin.h | 154 -- clang/lib/Headers/xmmintrin.h | 98 +++--- 3 files changed, 187 insertions(+), 107 deletions(-) diff --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h index ecd9bf18a41ca0..16f13a3fdfaf76 100644 --- a/clang/lib/Headers/avxintrin.h +++ b/clang/lib/Headers/avxintrin.h @@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPD instruction. @@ -226,6 +228,8 @@ _mm256_max_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPS instruction. @@ -245,6 +249,8 @@ _mm256_max_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPD instruction. @@ -264,6 +270,8 @@ _mm256_min_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPS instruction. @@ -1604,9 +1612,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [2 x double] vector consisting of two doubles corresponding to -///the two comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1663,9 +1671,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[4 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [4 x float] vector consisting of four floats corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1721,9 +1729,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///256-bit vectors of [4 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [4 x double] vector consisting of four doubles corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1781,9 +1789,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[8 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [8 x float] vector consisting of eight floats corresponding to -///the eight comparison results: zero if the comparison is false, and all -///1's if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1842,8 +1850,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///two 128-bit vectors of [2 x double], using the operation specified by the ///immediate integer op
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -710,6 +728,7 @@ _mm_cmpge_ps(__m128 __a, __m128 __b) /// ///The comparison yields 0x0 for false, 0x for true, in the ///low-order bits of a vector of [4 x float]. +///If either value in a comparison is NaN, returns false. pogo59 wrote: Yes, thank you! https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -1168,8 +1202,8 @@ _mm_comige_ss(__m128 __a, __m128 __b) ///operands to determine if the first operand is not equal to the second ///operand. /// -///The comparison returns 0 for false, 1 for true. If either of the two -///lower floating-point values is NaN, returns 0. pogo59 wrote: That was an existing mistake, but I agree, thanks! https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. pogo59 wrote: I didn't think so; @RKSimon ? https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -4743,7 +4771,9 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castsi128_pd(__m128i __a) { ///128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///Each comparison yields 0x0 for false, 0x for true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered pogo59 wrote: Done. I didn't like "marked" either, but couldn't come up with anything better. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/craigflores approved this pull request. This looks okay, but please consider my comments. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -513,7 +526,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpge_pd(__m128d __a, ///operand are ordered with respect to those in the second operand. /// ///A pair of double-precision values are "ordered" with respect to each craigflores wrote: Line 528: Remove the quotation marks around "ordered"? What do they add? Note that there are other instances of this (as well as "unordered" where the quotation marks are inserted) that I have not commented on. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/craigflores edited https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/craigflores edited https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -4743,7 +4771,9 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_castsi128_pd(__m128i __a) { ///128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///Each comparison yields 0x0 for false, 0x for true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered craigflores wrote: Say instead: "comparisons that are ordered return false, and comparisons that are unordered return true"? If no, I don't care for marked/unmarked. There are other instances of marked/unmarked that I have not flagged. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
@@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. phoebewang wrote: Is it worth to mention the ±0 comparison? https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
pogo59 wrote: cc @craigflores I have resisted the temptation to do a general editorial pass over these headers. This patch is "functional" in that it (mostly) adds information that was not provided before. There's a lot that could be done to make the descriptions more consistent with each other but I'll save that for another "nonfunctional" patch. The one editorial thing I did this time around was replace "yields" with "returns" since I was often touching those sentences anyway. https://github.com/llvm/llvm-project/pull/85862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Paul T Robinson (pogo59) Changes 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. --- Patch is 44.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/85862.diff 3 Files Affected: - (modified) clang/lib/Headers/avxintrin.h (+26-16) - (modified) clang/lib/Headers/emmintrin.h (+93-61) - (modified) clang/lib/Headers/xmmintrin.h (+68-30) ``diff diff --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h index ecd9bf18a41ca0..16f13a3fdfaf76 100644 --- a/clang/lib/Headers/avxintrin.h +++ b/clang/lib/Headers/avxintrin.h @@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPD instruction. @@ -226,6 +228,8 @@ _mm256_max_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPS instruction. @@ -245,6 +249,8 @@ _mm256_max_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPD instruction. @@ -264,6 +270,8 @@ _mm256_min_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPS instruction. @@ -1604,9 +1612,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [2 x double] vector consisting of two doubles corresponding to -///the two comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1663,9 +1671,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[4 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [4 x float] vector consisting of four floats corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1721,9 +1729,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///256-bit vectors of [4 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [4 x double] vector consisting of four doubles corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1781,9 +1789,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[8 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [8 x float] vector consisting of eight floats corresponding to -///the eight comparison results: zero if the comparison is false, and all -///1's if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1842,8 +1850,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///two 128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///If the result is true, all 64 bits of the destination vector are set; -///otherwise
[clang] [X86][Headers] Specify result of NaN comparisons (PR #85862)
https://github.com/pogo59 created https://github.com/llvm/llvm-project/pull/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. >From 5ed257ea248a5868cd3190bd1ad89413a1606370 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Tue, 19 Mar 2024 13:20:14 -0700 Subject: [PATCH] [X86][Headers] Specify result of NaN comparisons 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. --- clang/lib/Headers/avxintrin.h | 42 ++ clang/lib/Headers/emmintrin.h | 154 -- clang/lib/Headers/xmmintrin.h | 98 +++--- 3 files changed, 187 insertions(+), 107 deletions(-) diff --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h index ecd9bf18a41ca0..16f13a3fdfaf76 100644 --- a/clang/lib/Headers/avxintrin.h +++ b/clang/lib/Headers/avxintrin.h @@ -207,6 +207,8 @@ _mm256_div_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPD instruction. @@ -226,6 +228,8 @@ _mm256_max_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the greater ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMAXPS instruction. @@ -245,6 +249,8 @@ _mm256_max_ps(__m256 __a, __m256 __b) /// Compares two 256-bit vectors of [4 x double] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPD instruction. @@ -264,6 +270,8 @@ _mm256_min_pd(__m256d __a, __m256d __b) /// Compares two 256-bit vectors of [8 x float] and returns the lesser ///of each pair of values. /// +///If either value in a comparison is NaN, returns the value from \a __b. +/// /// \headerfile /// /// This intrinsic corresponds to the VMINPS instruction. @@ -1604,9 +1612,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///128-bit vectors of [2 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [2 x double] vector consisting of two doubles corresponding to -///the two comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1663,9 +1671,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[4 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [4 x float] vector consisting of four floats corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1721,9 +1729,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///256-bit vectors of [4 x double], using the operation specified by the ///immediate integer operand. /// -///Returns a [4 x double] vector consisting of four doubles corresponding to -///the four comparison results: zero if the comparison is false, and all 1's -///if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered return true. /// /// \headerfile /// @@ -1781,9 +1789,9 @@ _mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) ///[8 x float], using the operation specified by the immediate integer ///operand. /// -///Returns a [8 x float] vector consisting of eight floats corresponding to -///the eight comparison results: zero if the comparison is false, and all -///1's if the comparison is true. +///Each comparison returns 0x0 for false, 0x for true. +///If either value in a comparison is NaN, comparisons marked as ordered +///return false, and comparisons marked as unordered retur