lol
1diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h
2index bd06681..00172b7 100644
3--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h
4+++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h
5@@ -1,10 +1,36 @@
6+/**
7+ * Copyright (c) 2016-present, Facebook, Inc.
8+ *
9+ * Licensed under the Apache License, Version 2.0 (the "License");
10+ * you may not use this file except in compliance with the License.
11+ * You may obtain a copy of the License at
12+ *
13+ * http://www.apache.org/licenses/LICENSE-2.0
14+ *
15+ * Unless required by applicable law or agreed to in writing, software
16+ * distributed under the License is distributed on an "AS IS" BASIS,
17+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ * See the License for the specific language governing permissions and
19+ * limitations under the License.
20+ */
21+
22 #pragma once
23
24-#if defined(__APPLE__) && (__clang_major__ < 8)
25+// Apple clang was fixed in 8.1
26+#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
27+#define __APPLE_NEED_FIX 1
28+#endif
29+
30+// Regular clang was fixed in 3.9
31+#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9)
32+#define __CLANG_NEED_FIX 1
33+#endif
34+
35+#if __APPLE_NEED_FIX || __CLANG_NEED_FIX
36
37 #include <emmintrin.h>
38
39-// This version of apple clang has a bug that _cvtsh_ss is not defined, see
40+// This version of clang has a bug that _cvtsh_ss is not defined, see
41 // https://reviews.llvm.org/D16177
42 static __inline float
43 __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
44@@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a)
45 return r[0];
46 }
47
48-#endif // defined(__APPLE__) && (__clang_major__ < 8)
49+#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX
50+
51+#undef __APPLE_NEED_FIX
52+#undef __CLANG_NEED_FIX
53
54 #ifdef _MSC_VER
55