]> granicus.if.org Git - clang/commitdiff
[X86] Allow _mm_prefetch (both the header implementation and the builtin) to accept...
authorCraig Topper <craig.topper@intel.com>
Thu, 21 Dec 2017 23:50:22 +0000 (23:50 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 21 Dec 2017 23:50:22 +0000 (23:50 +0000)
Add the appropriate _MM_HINT_ET0/ET1 defines to match gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321325 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBuiltin.cpp
lib/Headers/xmmintrin.h
lib/Sema/SemaChecking.cpp

index 4294a579defe77fc51664a1cdbe2de94b4ff296a..609987c4fa4c8490298442cadaa70085bc0dfbda 100644 (file)
@@ -8022,8 +8022,9 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
   default: return nullptr;
   case X86::BI_mm_prefetch: {
     Value *Address = Ops[0];
-    Value *RW = ConstantInt::get(Int32Ty, 0);
-    Value *Locality = Ops[1];
+    ConstantInt *C = cast<ConstantInt>(Ops[1]);
+    Value *RW = ConstantInt::get(Int32Ty, (C->getZExtValue() >> 2) & 0x1);
+    Value *Locality = ConstantInt::get(Int32Ty, C->getZExtValue() & 0x3);
     Value *Data = ConstantInt::get(Int32Ty, 1);
     Value *F = CGM.getIntrinsic(Intrinsic::prefetch);
     return Builder.CreateCall(F, {Address, RW, Locality, Data});
index bbc2117b4ea11a661e5d7be22dd87c3814f36868..279c0275d93fd5fc683592e3323e84f0e473e762 100644 (file)
@@ -2035,9 +2035,11 @@ _mm_storer_ps(float *__p, __m128 __a)
   _mm_store_ps(__p, __a);
 }
 
-#define _MM_HINT_T0 3
-#define _MM_HINT_T1 2
-#define _MM_HINT_T2 1
+#define _MM_HINT_ET0 7
+#define _MM_HINT_ET1 6
+#define _MM_HINT_T0  3
+#define _MM_HINT_T1  2
+#define _MM_HINT_T2  1
 #define _MM_HINT_NTA 0
 
 #ifndef _MSC_VER
@@ -2068,7 +2070,8 @@ _mm_storer_ps(float *__p, __m128 __a)
 ///    be generated. \n
 ///    _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
 ///    be generated.
-#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), 0, (sel)))
+#define _mm_prefetch(a, sel) (__builtin_prefetch((void *)(a), \
+                                                 ((sel) >> 2) & 1, (sel) & 0x3))
 #endif
 
 /// \brief Stores a 64-bit integer in the specified aligned memory location. To
index 122ceab70e121678b63858e9231ce0dc5b430401..803f87b3c56869e13a1885d034bd2bdfaf3d3654 100644 (file)
@@ -2278,7 +2278,7 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
   default:
     return false;
   case X86::BI_mm_prefetch:
-    i = 1; l = 0; u = 3;
+    i = 1; l = 0; u = 7;
     break;
   case X86::BI__builtin_ia32_sha1rnds4:
   case X86::BI__builtin_ia32_shuf_f32x4_256_mask: