Skip to content

Commit b5995fc

Browse files
committed
[OpenCL] Limit popcount to OpenCL 1.2 and above
s6.15.3 of the OpenCL C Specification v3.0.6 states that OpenCL 1.2 or newer is required.
1 parent 44ce487 commit b5995fc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

clang/lib/Headers/opencl-c.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9907,6 +9907,7 @@ ulong16 __ovld __cnfn upsample(uint16 hi, uint16 lo);
99079907
/*
99089908
* popcount(x): returns the number of set bit in x
99099909
*/
9910+
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
99109911
char __ovld __cnfn popcount(char x);
99119912
uchar __ovld __cnfn popcount(uchar x);
99129913
char2 __ovld __cnfn popcount(char2 x);
@@ -9955,6 +9956,7 @@ long8 __ovld __cnfn popcount(long8 x);
99559956
ulong8 __ovld __cnfn popcount(ulong8 x);
99569957
long16 __ovld __cnfn popcount(long16 x);
99579958
ulong16 __ovld __cnfn popcount(ulong16 x);
9959+
#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
99589960

99599961
/**
99609962
* Multiply two 24-bit integer values x and y and add

clang/lib/Sema/OpenCLBuiltins.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,9 @@ foreach name = ["half_divide", "half_powr",
579579
foreach name = ["abs"] in {
580580
def : Builtin<name, [AI2UGenTypeN, AIGenTypeN], Attr.Const>;
581581
}
582-
foreach name = ["clz", "popcount"] in {
583-
def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>;
582+
def : Builtin<"clz", [AIGenTypeN, AIGenTypeN], Attr.Const>;
583+
let MinVersion = CL12 in {
584+
def : Builtin<"popcount", [AIGenTypeN, AIGenTypeN], Attr.Const>;
584585
}
585586
let MinVersion = CL20 in {
586587
foreach name = ["ctz"] in {

0 commit comments

Comments
 (0)