Skip to content

Commit 81c8c1c

Browse files
committed
[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
1 parent 59ea2ed commit 81c8c1c

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,7 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
23082308
case X86::BI__builtin_ia32_scatterpfdps:
23092309
case X86::BI__builtin_ia32_scatterpfqpd:
23102310
case X86::BI__builtin_ia32_scatterpfqps:
2311-
i = 4; l = 1; u = 2;
2311+
i = 4; l = 2; u = 3;
23122312
break;
23132313
case X86::BI__builtin_ia32_pcmpestrm128:
23142314
case X86::BI__builtin_ia32_pcmpestri128:

test/CodeGen/avx512pf-builtins.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,95 +6,95 @@
66
void test_mm512_mask_prefetch_i32gather_pd(__m256i index, __mmask8 mask, void const *addr, int hint) {
77
// CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_pd
88
// CHECK: @llvm.x86.avx512.gatherpf.dpd
9-
return _mm512_mask_prefetch_i32gather_pd(index, mask, addr, 2, 1);
9+
return _mm512_mask_prefetch_i32gather_pd(index, mask, addr, 2, _MM_HINT_T0);
1010
}
1111

1212
void test_mm512_prefetch_i32gather_pd(__m256i index, void const *addr, int hint) {
1313
// CHECK-LABEL: @test_mm512_prefetch_i32gather_pd
1414
// CHECK: @llvm.x86.avx512.gatherpf.dpd
15-
return _mm512_prefetch_i32gather_pd(index, addr, 2, 1);
15+
return _mm512_prefetch_i32gather_pd(index, addr, 2, _MM_HINT_T0);
1616
}
1717

1818
void test_mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, void const *addr, int hint) {
1919
// CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_ps
2020
// CHECK: @llvm.x86.avx512.gatherpf.dps
21-
return _mm512_mask_prefetch_i32gather_ps(index, mask, addr, 2, 1);
21+
return _mm512_mask_prefetch_i32gather_ps(index, mask, addr, 2, _MM_HINT_T0);
2222
}
2323

2424
void test_mm512_prefetch_i32gather_ps(__m512i index, void const *addr, int hint) {
2525
// CHECK-LABEL: @test_mm512_prefetch_i32gather_ps
2626
// CHECK: @llvm.x86.avx512.gatherpf.dps
27-
return _mm512_prefetch_i32gather_ps(index, addr, 2, 1);
27+
return _mm512_prefetch_i32gather_ps(index, addr, 2, _MM_HINT_T0);
2828
}
2929

3030
void test_mm512_mask_prefetch_i64gather_pd(__m512i index, __mmask8 mask, void const *addr, int hint) {
3131
// CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_pd
3232
// CHECK: @llvm.x86.avx512.gatherpf.qpd
33-
return _mm512_mask_prefetch_i64gather_pd(index, mask, addr, 2, 1);
33+
return _mm512_mask_prefetch_i64gather_pd(index, mask, addr, 2, _MM_HINT_T0);
3434
}
3535

3636
void test_mm512_prefetch_i64gather_pd(__m512i index, void const *addr, int hint) {
3737
// CHECK-LABEL: @test_mm512_prefetch_i64gather_pd
3838
// CHECK: @llvm.x86.avx512.gatherpf.qpd
39-
return _mm512_prefetch_i64gather_pd(index, addr, 2, 1);
39+
return _mm512_prefetch_i64gather_pd(index, addr, 2, _MM_HINT_T0);
4040
}
4141

4242
void test_mm512_mask_prefetch_i64gather_ps(__m512i index, __mmask8 mask, void const *addr, int hint) {
4343
// CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_ps
4444
// CHECK: @llvm.x86.avx512.gatherpf.qps
45-
return _mm512_mask_prefetch_i64gather_ps(index, mask, addr, 2, 1);
45+
return _mm512_mask_prefetch_i64gather_ps(index, mask, addr, 2, _MM_HINT_T0);
4646
}
4747

4848
void test_mm512_prefetch_i64gather_ps(__m512i index, void const *addr, int hint) {
4949
// CHECK-LABEL: @test_mm512_prefetch_i64gather_ps
5050
// CHECK: @llvm.x86.avx512.gatherpf.qps
51-
return _mm512_prefetch_i64gather_ps(index, addr, 2, 1);
51+
return _mm512_prefetch_i64gather_ps(index, addr, 2, _MM_HINT_T0);
5252
}
5353

5454
void test_mm512_prefetch_i32scatter_pd(void *addr, __m256i index) {
5555
// CHECK-LABEL: @test_mm512_prefetch_i32scatter_pd
5656
// CHECK: @llvm.x86.avx512.scatterpf.dpd.512
57-
return _mm512_prefetch_i32scatter_pd(addr, index, 1, 2);
57+
return _mm512_prefetch_i32scatter_pd(addr, index, 1, _MM_HINT_T1);
5858
}
5959

6060
void test_mm512_mask_prefetch_i32scatter_pd(void *addr, __mmask8 mask, __m256i index) {
6161
// CHECK-LABEL: @test_mm512_mask_prefetch_i32scatter_pd
6262
// CHECK: @llvm.x86.avx512.scatterpf.dpd.512
63-
return _mm512_mask_prefetch_i32scatter_pd(addr, mask, index, 1, 2);
63+
return _mm512_mask_prefetch_i32scatter_pd(addr, mask, index, 1, _MM_HINT_T1);
6464
}
6565

6666
void test_mm512_prefetch_i32scatter_ps(void *addr, __m512i index) {
6767
// CHECK-LABEL: @test_mm512_prefetch_i32scatter_ps
6868
// CHECK: @llvm.x86.avx512.scatterpf.dps.512
69-
return _mm512_prefetch_i32scatter_ps(addr, index, 1, 2);
69+
return _mm512_prefetch_i32scatter_ps(addr, index, 1, _MM_HINT_T1);
7070
}
7171

7272
void test_mm512_mask_prefetch_i32scatter_ps(void *addr, __mmask16 mask, __m512i index) {
7373
// CHECK-LABEL: @test_mm512_mask_prefetch_i32scatter_ps
7474
// CHECK: @llvm.x86.avx512.scatterpf.dps.512
75-
return _mm512_mask_prefetch_i32scatter_ps(addr, mask, index, 1, 2);
75+
return _mm512_mask_prefetch_i32scatter_ps(addr, mask, index, 1, _MM_HINT_T1);
7676
}
7777

7878
void test_mm512_prefetch_i64scatter_pd(void *addr, __m512i index) {
7979
// CHECK-LABEL: @test_mm512_prefetch_i64scatter_pd
8080
// CHECK: @llvm.x86.avx512.scatterpf.qpd.512
81-
return _mm512_prefetch_i64scatter_pd(addr, index, 1, 2);
81+
return _mm512_prefetch_i64scatter_pd(addr, index, 1, _MM_HINT_T1);
8282
}
8383

8484
void test_mm512_mask_prefetch_i64scatter_pd(void *addr, __mmask16 mask, __m512i index) {
8585
// CHECK-LABEL: @test_mm512_mask_prefetch_i64scatter_pd
8686
// CHECK: @llvm.x86.avx512.scatterpf.qpd.512
87-
return _mm512_mask_prefetch_i64scatter_pd(addr, mask, index, 1, 2);
87+
return _mm512_mask_prefetch_i64scatter_pd(addr, mask, index, 1, _MM_HINT_T1);
8888
}
8989

9090
void test_mm512_prefetch_i64scatter_ps(void *addr, __m512i index) {
9191
// CHECK-LABEL: @test_mm512_prefetch_i64scatter_ps
9292
// CHECK: @llvm.x86.avx512.scatterpf.qps.512
93-
return _mm512_prefetch_i64scatter_ps(addr, index, 1, 2);
93+
return _mm512_prefetch_i64scatter_ps(addr, index, 1, _MM_HINT_T1);
9494
}
9595

9696
void test_mm512_mask_prefetch_i64scatter_ps(void *addr, __mmask16 mask, __m512i index) {
9797
// CHECK-LABEL: @test_mm512_mask_prefetch_i64scatter_ps
9898
// CHECK: @llvm.x86.avx512.scatterpf.qps.512
99-
return _mm512_mask_prefetch_i64scatter_ps(addr, mask, index, 1, 2);
99+
return _mm512_mask_prefetch_i64scatter_ps(addr, mask, index, 1, _MM_HINT_T1);
100100
}

test/Sema/builtins-x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ __m512i _mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, int con
8080
}
8181

8282
__m512 _mm512_mask_prefetch_i32gather_ps_2(__m512i index, __mmask16 mask, int const *addr) {
83-
return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 3); // expected-error {{argument should be a value from 1 to 2}}
83+
return __builtin_ia32_gatherpfdps(mask, index, addr, 1, 1); // expected-error {{argument should be a value from 2 to 3}}
8484
}
8585

0 commit comments

Comments
 (0)