From: Craig Topper Date: Fri, 31 Mar 2017 17:22:30 +0000 (+0000) Subject: [Sema][X86] Update immediate check for gather/scatter prefetch instructions to match... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81c8c1c8c96129bf7f6ff36b8db85c414b0b1a95;p=clang [Sema][X86] Update immediate check for gather/scatter prefetch instructions to match the _MM_HINT_T0/T1 constant definitions Our _MM_HINT_T0/T1 constant values are 3/2 which matches gcc, but not icc or Intel documentation. Interestingly gcc had this same bug on their implementation of the gather/scatter builtins at one point too. Fixes PR32411. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299233 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 813a742f2c..81db0d3d00 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 19ee083eae..b35d90ca63 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 f7854381a3..074efe16ad 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}} }