Skip to content

Conversation

RKSimon
Copy link
Collaborator

@RKSimon RKSimon commented Sep 24, 2025

smmintrin.h redefines __DEFAULT_FN_ATTRS half way through the file to handle SSE42-only instructions - when we made _mm_cmpgt_epi64 constexpr we failed to redefine __DEFAULT_FN_ATTRS_CONSTEXPR as well to match

smmintrin.h redefines __DEFAULT_FN_ATTRS half way through the file to handle SSE42-only instructions - when we made _mm_cmpgt_epi64 constexpr we failed to redefine __DEFAULT_FN_ATTRS_CONSTEXPR as well to match
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Sep 24, 2025
@RKSimon RKSimon enabled auto-merge (squash) September 24, 2025 10:26
@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2025

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: Simon Pilgrim (RKSimon)

Changes

smmintrin.h redefines __DEFAULT_FN_ATTRS half way through the file to handle SSE42-only instructions - when we made _mm_cmpgt_epi64 constexpr we failed to redefine __DEFAULT_FN_ATTRS_CONSTEXPR as well to match


Full diff: https://github.com/llvm/llvm-project/pull/160491.diff

1 Files Affected:

  • (modified) clang/lib/Headers/smmintrin.h (+7)
diff --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index 6319fdbbeb8f0..3aff679b608ba 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -1534,9 +1534,16 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_minpos_epu16(__m128i __V) {
    so we'll do the same.  */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 #define __DEFAULT_FN_ATTRS                                                     \
   __attribute__((__always_inline__, __nodebug__, __target__("sse4.2")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /* These specify the type of data that we're comparing.  */
 #define _SIDD_UBYTE_OPS 0x00
 #define _SIDD_UWORD_OPS 0x01

@RKSimon RKSimon merged commit 5031c16 into llvm:main Sep 24, 2025
13 checks passed
@RKSimon RKSimon deleted the x86-sse42-pcmpgt-constexpr branch September 24, 2025 11:20
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…vm#160491)

smmintrin.h redefines __DEFAULT_FN_ATTRS half way through the file to
handle SSE42-only instructions - when we made _mm_cmpgt_epi64 constexpr
we failed to redefine __DEFAULT_FN_ATTRS_CONSTEXPR as well to match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants