Skip to content

Commit 03fef62

Browse files
authored
[AMDGPU] Relax __builtin_amdgcn_update_dpp sema check (#113341)
Recent change applied too strict check for old and src operands match. These shall be compatible, but not necessarily exactly the same. Fixes: SWDEV-493072
1 parent cc4926a commit 03fef62

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

clang/lib/Sema/SemaAMDGPU.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,19 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID,
9393
return true;
9494
}
9595
}
96-
if (ArgTys[0] != ArgTys[1]) {
97-
SemaRef.Diag(Args[1]->getBeginLoc(),
98-
diag::err_typecheck_call_different_arg_types)
99-
<< ArgTys[0] << ArgTys[1];
100-
return true;
101-
}
102-
return false;
96+
if (getASTContext().hasSameUnqualifiedType(ArgTys[0], ArgTys[1]))
97+
return false;
98+
if (((ArgTys[0]->isUnsignedIntegerType() &&
99+
ArgTys[1]->isSignedIntegerType()) ||
100+
(ArgTys[0]->isSignedIntegerType() &&
101+
ArgTys[1]->isUnsignedIntegerType())) &&
102+
getASTContext().getTypeSize(ArgTys[0]) ==
103+
getASTContext().getTypeSize(ArgTys[1]))
104+
return false;
105+
SemaRef.Diag(Args[1]->getBeginLoc(),
106+
diag::err_typecheck_call_different_arg_types)
107+
<< ArgTys[0] << ArgTys[1];
108+
return true;
103109
}
104110
default:
105111
return false;

clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,29 @@ void test_update_dpp_half(half *x, global half *p) {
218218
*p = __builtin_amdgcn_update_dpp(*x, *x, 0x101, 0xf, 0xf, 0);
219219
}
220220

221+
// CHECK-LABEL: @test_update_dpp_int_uint
222+
// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 %arg1, i32 %arg2, i32 0, i32 0, i32 0, i1 false)
223+
void test_update_dpp_int_uint(global int* out, int arg1, unsigned int arg2)
224+
{
225+
*out = __builtin_amdgcn_update_dpp(arg1, arg2, 0, 0, 0, false);
226+
}
227+
228+
// CHECK-LABEL: @test_update_dpp_lit_int
229+
// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 5, i32 %arg1, i32 0, i32 0, i32 0, i1 false)
230+
void test_update_dpp_lit_int(global int* out, int arg1)
231+
{
232+
*out = __builtin_amdgcn_update_dpp(5, arg1, 0, 0, 0, false);
233+
}
234+
235+
__constant int gi = 5;
236+
237+
// CHECK-LABEL: @test_update_dpp_const_int
238+
// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.update.dpp.i32(i32 5, i32 %arg1, i32 0, i32 0, i32 0, i1 false)
239+
void test_update_dpp_const_int(global int* out, int arg1)
240+
{
241+
*out = __builtin_amdgcn_update_dpp(gi, arg1, 0, 0, 0, false);
242+
}
243+
221244
// CHECK-LABEL: @test_ds_fadd
222245
// CHECK: atomicrmw fadd ptr addrspace(3) %out, float %src monotonic, align 4{{$}}
223246
// CHECK: atomicrmw volatile fadd ptr addrspace(3) %out, float %src monotonic, align 4{{$}}

clang/test/SemaOpenCL/builtins-amdgcn-error-gfx9.cl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ void test_update_dpp(global int* out, int arg1, int arg2, int i, int2 i2, long l
5656
*out = __builtin_amdgcn_update_dpp(fc, arg2, 0, 0, 0, false); // expected-error{{used type '__private _Complex float' where integer or floating point type is required}}
5757
*out = __builtin_amdgcn_update_dpp(arg1, fc, 0, 0, 0, false); // expected-error{{used type '__private _Complex float' where integer or floating point type is required}}
5858
*out = __builtin_amdgcn_update_dpp(i, l, 0, 0, 0, false); // expected-error{{arguments are of different types ('__private int' vs '__private long')}}
59+
*out = __builtin_amdgcn_update_dpp(0.5f, i, 0, 0, 0, false); // expected-error{{arguments are of different types ('float' vs '__private int')}}
5960
}

0 commit comments

Comments
 (0)