From d7dd7755fc5092c69f492d6f32cb0e34e63c6a53 Mon Sep 17 00:00:00 2001
From: Chad Rosier <mcrosier@apple.com>
Date: Sat, 17 Dec 2011 01:51:05 +0000
Subject: [PATCH] Fix _mm_permute_ps and _mm256_permute_ps AVX intrinsics to
 use "I" (ICE) markings.  Fix avxintrin.h to take them into account. Part of
 rdar://10595450

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146810 91177308-0d34-0410-b5e6-96231b3b80d8
---
 include/clang/Basic/BuiltinsX86.def |  4 ++--
 lib/Headers/avxintrin.h             | 16 ++++++----------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def
index 832b4163206..2a733109547 100644
--- a/include/clang/Basic/BuiltinsX86.def
+++ b/include/clang/Basic/BuiltinsX86.def
@@ -426,9 +426,9 @@ BUILTIN(__builtin_ia32_vperm2f128_pd256, "V4dV4dV4dIc", "")
 BUILTIN(__builtin_ia32_vperm2f128_ps256, "V8fV8fV8fIc", "")
 BUILTIN(__builtin_ia32_vperm2f128_si256, "V8iV8iV8iIc", "")
 BUILTIN(__builtin_ia32_vpermilpd, "V2dV2dIc", "")
-BUILTIN(__builtin_ia32_vpermilps, "V4fV4fc", "")
+BUILTIN(__builtin_ia32_vpermilps, "V4fV4fIc", "")
 BUILTIN(__builtin_ia32_vpermilpd256, "V4dV4dIc", "")
-BUILTIN(__builtin_ia32_vpermilps256, "V8fV8fc", "")
+BUILTIN(__builtin_ia32_vpermilps256, "V8fV8fIc", "")
 BUILTIN(__builtin_ia32_vinsertf128_pd256, "V4dV4dV2dIc", "")
 BUILTIN(__builtin_ia32_vinsertf128_ps256, "V8fV8fV4fIc", "")
 BUILTIN(__builtin_ia32_vinsertf128_si256, "V8iV8iV4iIc", "")
diff --git a/lib/Headers/avxintrin.h b/lib/Headers/avxintrin.h
index 64ab67b5859..d33a0763926 100644
--- a/lib/Headers/avxintrin.h
+++ b/lib/Headers/avxintrin.h
@@ -266,17 +266,13 @@ _mm256_permutevar_ps(__m256 a, __m256i c)
   __m256d __A = (A); \
   (__m256d)__builtin_ia32_vpermilpd256((__v4df)__A, C); })
 
-static __inline __m128 __attribute__((__always_inline__, __nodebug__))
-_mm_permute_ps(__m128 a, const int c)
-{
-  return (__m128)__builtin_ia32_vpermilps((__v4sf)a, c);
-}
+#define _mm_permute_ps(A, C) __extension__ ({ \
+  __m128 __A = (A); \
+  (__m128)__builtin_ia32_vpermilps((__v4sf)__A, C); })
 
-static __inline __m256 __attribute__((__always_inline__, __nodebug__))
-_mm256_permute_ps(__m256 a, const int c)
-{
-  return (__m256)__builtin_ia32_vpermilps256((__v8sf)a, c);
-}
+#define _mm256_permute_ps(A, C) __extension__ ({ \
+  __m256 __A = (A); \
+  (__m256)__builtin_ia32_vpermilps256((__v8sf)__A, C); })
 
 #define _mm256_permute2f128_pd(V1, V2, M) __extension__ ({ \
   __m256d __V1 = (V1); \
-- 
GitLab