Re: r269675 - [ms] Reintroduce feature guards in intrinsic headers in Microsoft mode

2016-05-17 Thread Eric Christopher via cfe-commits
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?

What "better intrinsic story" are you looking for? This doesn't seem
related to the PR you reference.

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?

-eric

On Mon, May 16, 2016 at 11:20 AM Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Mon May 16 13:14:07 2016
> New Revision: 269675
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269675=rev
> Log:
> [ms] Reintroduce feature guards in intrinsic headers in Microsoft mode
>
> Visual Studio's C++ standard library headers include intrin.h, so the
> intrinsic
> headers get included a lot more often in Microsoft mode than elsewhere. The
> AVX512 intrinsics are a lot of code (0.7 MB, causing 30% compile time
> overhead
> for small programs including e.g.  and 6% compile time overhead for
> larger projects like e.g. v8). Since multiversioning can't be relied on in
> Microsoft mode (cl.exe doesn't support it), having faster compiles seems
> like
> the much better tradeoff until we have a better intrinsic story going
> forward
> (which we'll need for e.g. PR19898).
>
> Actually using intrinsics on Windows already requires the right /arch:
> settings, so this patch should have no big behavior change.
>
> See also thread "The intrinsics headers (especially avx512) are too big.
> What
> to do about it?" on cfe-dev.
>
> http://reviews.llvm.org/D20291
>
> Modified:
> cfe/trunk/lib/Headers/immintrin.h
> cfe/trunk/lib/Headers/x86intrin.h
> cfe/trunk/test/CodeGen/ms-mm-align.c
>
> Modified: cfe/trunk/lib/Headers/immintrin.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=269675=269674=269675=diff
>
> ==
> --- cfe/trunk/lib/Headers/immintrin.h (original)
> +++ cfe/trunk/lib/Headers/immintrin.h Mon May 16 13:14:07 2016
> @@ -24,22 +24,41 @@
>  #ifndef __IMMINTRIN_H
>  #define __IMMINTRIN_H
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MMX__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE2__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE3__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSSE3__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || \
> +(defined(__SSE4_2__) || defined(__SSE4_1__))
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || \
> +(defined(__AES__) || defined(__PCLMUL__))
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__)
>  #include 
>
>  /* The 256-bit versions of functions in f16cintrin.h.
> @@ -54,45 +73,90 @@ _mm256_cvtph_ps(__m128i __a)
>  {
>return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
>  }
> +#endif /* __AVX2__ */
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || \
> +(defined(__AVX512VL__) && defined(__AVX512BW__))
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || \
> +(defined(__AVX512VL__) && defined(__AVX512CD__))
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || \
> +(defined(__AVX512VL__) && defined(__AVX512DQ__))
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512ER__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) ||
> defined(__AVX512IFMA__)
>  #include 
> +#endif
>
> +#if !defined(_MSC_VER) || __has_feature(modules) 

r269675 - [ms] Reintroduce feature guards in intrinsic headers in Microsoft mode

2016-05-16 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon May 16 13:14:07 2016
New Revision: 269675

URL: http://llvm.org/viewvc/llvm-project?rev=269675=rev
Log:
[ms] Reintroduce feature guards in intrinsic headers in Microsoft mode

Visual Studio's C++ standard library headers include intrin.h, so the intrinsic
headers get included a lot more often in Microsoft mode than elsewhere. The
AVX512 intrinsics are a lot of code (0.7 MB, causing 30% compile time overhead
for small programs including e.g.  and 6% compile time overhead for
larger projects like e.g. v8). Since multiversioning can't be relied on in
Microsoft mode (cl.exe doesn't support it), having faster compiles seems like
the much better tradeoff until we have a better intrinsic story going forward
(which we'll need for e.g. PR19898).

Actually using intrinsics on Windows already requires the right /arch:
settings, so this patch should have no big behavior change.

See also thread "The intrinsics headers (especially avx512) are too big. What
to do about it?" on cfe-dev.

http://reviews.llvm.org/D20291

Modified:
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/lib/Headers/x86intrin.h
cfe/trunk/test/CodeGen/ms-mm-align.c

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=269675=269674=269675=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Mon May 16 13:14:07 2016
@@ -24,22 +24,41 @@
 #ifndef __IMMINTRIN_H
 #define __IMMINTRIN_H
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MMX__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE2__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSE3__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SSSE3__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__SSE4_2__) || defined(__SSE4_1__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AES__) || defined(__PCLMUL__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__)
 #include 
 
 /* The 256-bit versions of functions in f16cintrin.h.
@@ -54,45 +73,90 @@ _mm256_cvtph_ps(__m128i __a)
 {
   return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
 }
+#endif /* __AVX2__ */
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512VL__) && defined(__AVX512BW__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512VL__) && defined(__AVX512CD__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512VL__) && defined(__AVX512DQ__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512ER__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512IFMA__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512IFMA__) && defined(__AVX512VL__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VBMI__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512VBMI__) && defined(__AVX512VL__))
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512PF__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PKU__)
 #include 
+#endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDRND__)
 static __inline__ int __attribute__((__always_inline__, __nodebug__, 
__target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
@@ -112,7 +176,9 @@ _rdrand64_step(unsigned long long *__p)
   return __builtin_ia32_rdrand64_step(__p);
 }
 #endif
+#endif /* __RDRND__ */
 
+#if