[Openmp-commits] [openmp] r360062 - Add non-SSE wrapper for __kmp_{load, store}_mxcsr

Dimitry Andric via Openmp-commits openmp-commits at lists.llvm.org
Mon May 6 10:58:04 PDT 2019

Author: dim
Date: Mon May  6 10:58:03 2019
New Revision: 360062

URL: http://llvm.org/viewvc/llvm-project?rev=360062&view=rev
Add non-SSE wrapper for __kmp_{load,store}_mxcsr

To be able to successfully build OpenMP on FreeBSD/i386, which still
uses i486 as its default processor, I had to provide wrappers for the
`__kmp_load_mxcsr` and `__kmp_store_mxcsr` functions.

If the compiler signals that SSE is not available, loading and storing
mxcsr does not make sense anway, so in that case the inline functions
are empty.  This gives the minimum amount of code churn.

See also https://svnweb.freebsd.org/changeset/base/345283

Reviewers: emaste, jlpeyton, Hahnfeld

Reviewed By: jlpeyton

Subscribers: hfinkel, krytarowski, jdoerfert, openmp-commits, llvm-commits

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D60916


Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=360062&r1=360061&r2=360062&view=diff
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Mon May  6 10:58:03 2019
@@ -1243,16 +1243,22 @@ static inline void __kmp_clear_x87_fpu_s
   __asm__ __volatile__("fnclex");
 #endif // KMP_MIC
+#if __SSE__
+static inline void __kmp_load_mxcsr(const kmp_uint32 *p) { _mm_setcsr(*p); }
+static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = _mm_getcsr(); }
+static inline void __kmp_load_mxcsr(const kmp_uint32 *p) {}
+static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = 0; }
 // Windows still has these as external functions in assembly file
 extern void __kmp_x86_cpuid(int mode, int mode2, struct kmp_cpuid *p);
 extern void __kmp_load_x87_fpu_control_word(const kmp_int16 *p);
 extern void __kmp_store_x87_fpu_control_word(kmp_int16 *p);
 extern void __kmp_clear_x87_fpu_status_word();
-#endif // KMP_OS_UNIX
-#define __kmp_load_mxcsr(p) _mm_setcsr(*(p))
+static inline void __kmp_load_mxcsr(const kmp_uint32 *p) { _mm_setcsr(*p); }
 static inline void __kmp_store_mxcsr(kmp_uint32 *p) { *p = _mm_getcsr(); }
+#endif // KMP_OS_UNIX
 #define KMP_X86_MXCSR_MASK 0xffffffc0 /* ignore status flags (6 lsb) */

More information about the Openmp-commits mailing list