diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 813a742f2c626f01dcec5d9c3deb73a8f79adbf7..81db0d3d00a7d5f3209c17b28855cd0d184909ff 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2308,7 +2308,7 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
   case X86::BI__builtin_ia32_scatterpfdps:
   case X86::BI__builtin_ia32_scatterpfqpd:
   case X86::BI__builtin_ia32_scatterpfqps:
-    i = 4; l = 1; u = 2;
+    i = 4; l = 2; u = 3;
     break;
   case X86::BI__builtin_ia32_pcmpestrm128:
   case X86::BI__builtin_ia32_pcmpestri128:
diff --git a/test/CodeGen/avx512pf-builtins.c b/test/CodeGen/avx512pf-builtins.c
index 19ee083eae2dfe350f7e766f57d57ec20f9dd6f3..b35d90ca6309689b48075036d7bbc505e0fa0306 100644
--- a/test/CodeGen/avx512pf-builtins.c
+++ b/test/CodeGen/avx512pf-builtins.c
@@ -6,95 +6,95 @@
 void test_mm512_mask_prefetch_i32gather_pd(__m256i index, __mmask8 mask, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.dpd
-  return _mm512_mask_prefetch_i32gather_pd(index, mask, addr, 2, 1); 
+  return _mm512_mask_prefetch_i32gather_pd(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_prefetch_i32gather_pd(__m256i index, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_prefetch_i32gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.dpd
-  return _mm512_prefetch_i32gather_pd(index, addr, 2, 1); 
+  return _mm512_prefetch_i32gather_pd(index, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.dps
-  return _mm512_mask_prefetch_i32gather_ps(index, mask, addr, 2, 1); 
+  return _mm512_mask_prefetch_i32gather_ps(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_prefetch_i32gather_ps(__m512i index,  void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_prefetch_i32gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.dps
-  return _mm512_prefetch_i32gather_ps(index, addr, 2, 1); 
+  return _mm512_prefetch_i32gather_ps(index, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_mask_prefetch_i64gather_pd(__m512i index, __mmask8 mask, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.qpd
-  return _mm512_mask_prefetch_i64gather_pd(index, mask, addr, 2, 1); 
+  return _mm512_mask_prefetch_i64gather_pd(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_prefetch_i64gather_pd(__m512i index, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_prefetch_i64gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.qpd
-  return _mm512_prefetch_i64gather_pd(index, addr, 2, 1); 
+  return _mm512_prefetch_i64gather_pd(index, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_mask_prefetch_i64gather_ps(__m512i index, __mmask8 mask, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.qps
-  return _mm512_mask_prefetch_i64gather_ps(index, mask, addr, 2, 1); 
+  return _mm512_mask_prefetch_i64gather_ps(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_prefetch_i64gather_ps(__m512i index, void const *addr, int hint) {
   // CHECK-LABEL: @test_mm512_prefetch_i64gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.qps
-  return _mm512_prefetch_i64gather_ps(index, addr, 2, 1); 
+  return _mm512_prefetch_i64gather_ps(index, addr, 2, _MM_HINT_T0); 
 }
 
 void test_mm512_prefetch_i32scatter_pd(void *addr, __m256i index) {
   // CHECK-LABEL: @test_mm512_prefetch_i32scatter_pd
   // CHECK: @llvm.x86.avx512.scatterpf.dpd.512
-  return _mm512_prefetch_i32scatter_pd(addr, index, 1, 2); 
+  return _mm512_prefetch_i32scatter_pd(addr, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_mask_prefetch_i32scatter_pd(void *addr, __mmask8 mask, __m256i index) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32scatter_pd
   // CHECK: @llvm.x86.avx512.scatterpf.dpd.512
-  return _mm512_mask_prefetch_i32scatter_pd(addr, mask, index, 1, 2); 
+  return _mm512_mask_prefetch_i32scatter_pd(addr, mask, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_prefetch_i32scatter_ps(void *addr, __m512i index) {
   // CHECK-LABEL: @test_mm512_prefetch_i32scatter_ps
   // CHECK: @llvm.x86.avx512.scatterpf.dps.512
-  return _mm512_prefetch_i32scatter_ps(addr, index, 1, 2); 
+  return _mm512_prefetch_i32scatter_ps(addr, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_mask_prefetch_i32scatter_ps(void *addr, __mmask16 mask, __m512i index) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32scatter_ps
   // CHECK: @llvm.x86.avx512.scatterpf.dps.512
-  return _mm512_mask_prefetch_i32scatter_ps(addr, mask, index, 1, 2); 
+  return _mm512_mask_prefetch_i32scatter_ps(addr, mask, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_prefetch_i64scatter_pd(void *addr, __m512i index) {
   // CHECK-LABEL: @test_mm512_prefetch_i64scatter_pd
   // CHECK: @llvm.x86.avx512.scatterpf.qpd.512
-  return _mm512_prefetch_i64scatter_pd(addr, index, 1, 2); 
+  return _mm512_prefetch_i64scatter_pd(addr, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_mask_prefetch_i64scatter_pd(void *addr, __mmask16 mask, __m512i index) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64scatter_pd
   // CHECK: @llvm.x86.avx512.scatterpf.qpd.512
-  return _mm512_mask_prefetch_i64scatter_pd(addr, mask, index, 1, 2); 
+  return _mm512_mask_prefetch_i64scatter_pd(addr, mask, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_prefetch_i64scatter_ps(void *addr, __m512i index) {
   // CHECK-LABEL: @test_mm512_prefetch_i64scatter_ps
   // CHECK: @llvm.x86.avx512.scatterpf.qps.512
-  return _mm512_prefetch_i64scatter_ps(addr, index, 1, 2); 
+  return _mm512_prefetch_i64scatter_ps(addr, index, 1, _MM_HINT_T1); 
 }
 
 void test_mm512_mask_prefetch_i64scatter_ps(void *addr, __mmask16 mask, __m512i index) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64scatter_ps
   // CHECK: @llvm.x86.avx512.scatterpf.qps.512
-  return _mm512_mask_prefetch_i64scatter_ps(addr, mask, index, 1, 2); 
+  return _mm512_mask_prefetch_i64scatter_ps(addr, mask, index, 1, _MM_HINT_T1); 
 }
diff --git a/test/Sema/builtins-x86.c b/test/Sema/builtins-x86.c
index f7854381a352647ecef78d5402ca26bf82b7f7ca..074efe16ade6b66eeaaebc8c1c33e4d4445aa9c1 100644
--- a/test/Sema/builtins-x86.c
+++ b/test/Sema/builtins-x86.c
@@ -80,6 +80,6 @@ __m512i _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int con
 }
 
 __m512 _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) {
-  return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 3); // expected-error {{argument should be a value from 1 to 2}}
+  return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument should be a value from 2 to 3}}
 }