<div dir="ltr">So, why are you doing this for more than just the avx512 headers? I understand that you're unhappy with all of the intrinsics, but you've added an incompatibility here for MS mode. Does MS use header guards locking off particular intrinsics?<div><br></div><div>What "better intrinsic story" are you looking for? This doesn't seem related to the PR you reference.</div><div><br></div><div>As far as using the right /arch, that's true, however, you should be getting an error from the front end rather than an error in the backend - what's up with that?<br><div><br></div><div>-eric</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, May 16, 2016 at 11:20 AM Nico Weber via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nico<br>
Date: Mon May 16 13:14:07 2016<br>
New Revision: 269675<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=269675&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=269675&view=rev</a><br>
Log:<br>
[ms] Reintroduce feature guards in intrinsic headers in Microsoft mode<br>
<br>
Visual Studio's C++ standard library headers include intrin.h, so the intrinsic<br>
headers get included a lot more often in Microsoft mode than elsewhere. The<br>
AVX512 intrinsics are a lot of code (0.7 MB, causing 30% compile time overhead<br>
for small programs including e.g. <string> and 6% compile time overhead for<br>
larger projects like e.g. v8). Since multiversioning can't be relied on in<br>
Microsoft mode (cl.exe doesn't support it), having faster compiles seems like<br>
the much better tradeoff until we have a better intrinsic story going forward<br>
(which we'll need for e.g. PR19898).<br>
<br>
Actually using intrinsics on Windows already requires the right /arch:<br>
settings, so this patch should have no big behavior change.<br>
<br>
See also thread "The intrinsics headers (especially avx512) are too big. What<br>
to do about it?" on cfe-dev.<br>
<br>
<a href="http://reviews.llvm.org/D20291" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20291</a><br>
<br>
Modified:<br>
    cfe/trunk/lib/Headers/immintrin.h<br>
    cfe/trunk/lib/Headers/x86intrin.h<br>
    cfe/trunk/test/CodeGen/ms-mm-align.c<br>
<br>
Modified: cfe/trunk/lib/Headers/immintrin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=269675&r1=269674&r2=269675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=269675&r1=269674&r2=269675&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/immintrin.h (original)<br>
+++ cfe/trunk/lib/Headers/immintrin.h Mon May 16 13:14:07 2016<br>
@@ -24,22 +24,41 @@<br>
 #ifndef __IMMINTRIN_H<br>
 #define __IMMINTRIN_H<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MMX__)<br>
 #include <mmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE__)<br>
 #include <xmmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE2__)<br>
 #include <emmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE3__)<br>
 #include <pmmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSSE3__)<br>
 #include <tmmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__SSE4_2__) || defined(__SSE4_1__))<br>
 #include <smmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AES__) || defined(__PCLMUL__))<br>
 #include <wmmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)<br>
 #include <avxintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__)<br>
 #include <avx2intrin.h><br>
<br>
 /* The 256-bit versions of functions in f16cintrin.h.<br>
@@ -54,45 +73,90 @@ _mm256_cvtph_ps(__m128i __a)<br>
 {<br>
   return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);<br>
 }<br>
+#endif /* __AVX2__ */<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__)<br>
 #include <bmiintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__)<br>
 #include <bmi2intrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__)<br>
 #include <lzcntintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__)<br>
 #include <fmaintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__)<br>
 #include <avx512fintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__)<br>
 #include <avx512vlintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__)<br>
 #include <avx512bwintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__)<br>
 #include <avx512cdintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__)<br>
 #include <avx512dqintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AVX512VL__) && defined(__AVX512BW__))<br>
 #include <avx512vlbwintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AVX512VL__) && defined(__AVX512CD__))<br>
 #include <avx512vlcdintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AVX512VL__) && defined(__AVX512DQ__))<br>
 #include <avx512vldqintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512ER__)<br>
 #include <avx512erintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512IFMA__)<br>
 #include <avx512ifmaintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AVX512IFMA__) && defined(__AVX512VL__))<br>
 #include <avx512ifmavlintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VBMI__)<br>
 #include <avx512vbmiintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || \<br>
+    (defined(__AVX512VBMI__) && defined(__AVX512VL__))<br>
 #include <avx512vbmivlintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512PF__)<br>
 #include <avx512pfintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PKU__)<br>
 #include <pkuintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDRND__)<br>
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))<br>
 _rdrand16_step(unsigned short *__p)<br>
 {<br>
@@ -112,7 +176,9 @@ _rdrand64_step(unsigned long long *__p)<br>
   return __builtin_ia32_rdrand64_step(__p);<br>
 }<br>
 #endif<br>
+#endif /* __RDRND__ */<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FSGSBASE__)<br>
 #ifdef __x86_64__<br>
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))<br>
 _readfsbase_u32(void)<br>
@@ -162,22 +228,36 @@ _writegsbase_u64(unsigned long long __V)<br>
   return __builtin_ia32_wrgsbase64(__V);<br>
 }<br>
 #endif<br>
+#endif /* __FSGSBASE__ */<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__RTM__)<br>
 #include <rtmintrin.h><br>
-<br>
 #include <xtestintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SHA__)<br>
 #include <shaintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FXSR__)<br>
 #include <fxsrintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVE__)<br>
 #include <xsaveintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEOPT__)<br>
 #include <xsaveoptintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVEC__)<br>
 #include <xsavecintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XSAVES__)<br>
 #include <xsavesintrin.h><br>
+#endif<br>
<br>
 /* Some intrinsics inside adxintrin.h are available only on processors with ADX,<br>
  * whereas others are also available at all times. */<br>
<br>
Modified: cfe/trunk/lib/Headers/x86intrin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=269675&r1=269674&r2=269675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=269675&r1=269674&r2=269675&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Headers/x86intrin.h (original)<br>
+++ cfe/trunk/lib/Headers/x86intrin.h Mon May 16 13:14:07 2016<br>
@@ -28,29 +28,53 @@<br>
<br>
 #include <immintrin.h><br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__3dNOW__)<br>
 #include <mm3dnow.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__)<br>
 #include <bmiintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__)<br>
 #include <bmi2intrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__)<br>
 #include <lzcntintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__POPCNT__)<br>
 #include <popcntintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDSEED__)<br>
 #include <rdseedintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PRFCHW__)<br>
 #include <prfchwintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE4A__)<br>
 #include <ammintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA4__)<br>
 #include <fma4intrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__XOP__)<br>
 #include <xopintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__TBM__)<br>
 #include <tbmintrin.h><br>
+#endif<br>
<br>
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__F16C__)<br>
 #include <f16cintrin.h><br>
+#endif<br>
<br>
 /* FIXME: LWP */<br>
<br>
<br>
Modified: cfe/trunk/test/CodeGen/ms-mm-align.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-mm-align.c?rev=269675&r1=269674&r2=269675&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-mm-align.c?rev=269675&r1=269674&r2=269675&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/ms-mm-align.c (original)<br>
+++ cfe/trunk/test/CodeGen/ms-mm-align.c Mon May 16 13:14:07 2016<br>
@@ -1,4 +1,4 @@<br>
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \<br>
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -target-feature +sse \<br>
 // RUN:         -triple i686--windows -emit-llvm %s -o - \<br>
 // RUN:         | FileCheck %s -check-prefix CHECK<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>