diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index c15e58e9d28b1..ff74bda91545f 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -165,38 +165,14 @@ static bool IsSyclMathFunc(unsigned BuiltinID) { case Builtin::BI__builtin_truncl: case Builtin::BIlroundl: case Builtin::BI__builtin_lroundl: - case Builtin::BIcopysign: - case Builtin::BI__builtin_copysign: - case Builtin::BIfloor: - case Builtin::BI__builtin_floor: case Builtin::BIfmax: case Builtin::BI__builtin_fmax: case Builtin::BIfmin: case Builtin::BI__builtin_fmin: - case Builtin::BInearbyint: - case Builtin::BI__builtin_nearbyint: - case Builtin::BIrint: - case Builtin::BI__builtin_rint: - case Builtin::BIround: - case Builtin::BI__builtin_round: - case Builtin::BItrunc: - case Builtin::BI__builtin_trunc: - case Builtin::BIcopysignf: - case Builtin::BI__builtin_copysignf: - case Builtin::BIfloorf: - case Builtin::BI__builtin_floorf: case Builtin::BIfmaxf: case Builtin::BI__builtin_fmaxf: case Builtin::BIfminf: case Builtin::BI__builtin_fminf: - case Builtin::BInearbyintf: - case Builtin::BI__builtin_nearbyintf: - case Builtin::BIrintf: - case Builtin::BI__builtin_rintf: - case Builtin::BIroundf: - case Builtin::BI__builtin_roundf: - case Builtin::BItruncf: - case Builtin::BI__builtin_truncf: case Builtin::BIlroundf: case Builtin::BI__builtin_lroundf: case Builtin::BI__builtin_fpclassify: diff --git a/clang/test/SemaSYCL/supported_math.cpp b/clang/test/SemaSYCL/supported_math.cpp new file mode 100644 index 0000000000000..aada7829ef781 --- /dev/null +++ b/clang/test/SemaSYCL/supported_math.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -Wno-sycl-strict -verify %s +extern "C" float sinf(float); +extern "C" float cosf(float); +extern "C" float floorf(float); +extern "C" float logf(float); +extern "C" float nearbyintf(float); +extern "C" float rintf(float); +extern "C" float roundf(float); +extern "C" float truncf(float); +extern "C" float copysignf(float, float); +extern "C" double sin(double); +extern "C" double cos(double); +extern "C" double floor(double); +extern "C" double log(double); +extern "C" double nearbyint(double); +extern "C" double rint(double); +extern "C" double round(double); +extern "C" double trunc(double); +extern "C" double copysign(double, double); +template +__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) { + kernelFunc(); +} + +int main() { + kernel([=]() { + int acc[1] = {5}; + acc[0] *= 2; + acc[0] += (int)truncf(1.0f); // expected-no-diagnostics + acc[0] += (int)trunc(1.0); // expected-no-diagnostics + acc[0] += (int)roundf(1.0f); // expected-no-diagnostics + acc[0] += (int)round(1.0); // expected-no-diagnostics + acc[0] += (int)rintf(1.0f); // expected-no-diagnostics + acc[0] += (int)rint(1.0); // expected-no-diagnostics + acc[0] += (int)nearbyintf(0.5f); // expected-no-diagnostics + acc[0] += (int)nearbyint(0.5); // expected-no-diagnostics + acc[0] += (int)floorf(0.5f); // expected-no-diagnostics + acc[0] += (int)floor(0.5); // expected-no-diagnostics + acc[0] += (int)copysignf(1.0f, -0.5f); // expected-no-diagnostics + acc[0] += (int)copysign(1.0, -0.5); // expected-no-diagnostics + acc[0] += (int)sinf(1.0f); // expected-no-diagnostics + acc[0] += (int)sin(1.0); // expected-no-diagnostics + acc[0] += (int)__builtin_sinf(1.0f); // expected-no-diagnostics + acc[0] += (int)__builtin_sin(1.0); // expected-no-diagnostics + acc[0] += (int)cosf(1.0f); // expected-no-diagnostics + acc[0] += (int)cos(1.0); // expected-no-diagnostics + acc[0] += (int)__builtin_cosf(1.0f); // expected-no-diagnostics + acc[0] += (int)__builtin_cos(1.0); // expected-no-diagnostics + acc[0] += (int)logf(1.0f); // expected-no-diagnostics + acc[0] += (int)log(1.0); // expected-no-diagnostics + acc[0] += (int)__builtin_truncf(1.0f); // expected-no-diagnostics + acc[0] += (int)__builtin_trunc(1.0); // expected-no-diagnostics + acc[0] += (int)__builtin_rintf(1.0f); // expected-no-diagnostics + acc[0] += (int)__builtin_rint(1.0); // expected-no-diagnostics + acc[0] += (int)__builtin_nearbyintf(0.5f); // expected-no-diagnostics + acc[0] += (int)__builtin_nearbyint(0.5); // expected-no-diagnostics + acc[0] += (int)__builtin_floorf(0.5f); // expected-no-diagnostics + acc[0] += (int)__builtin_floor(0.5); // expected-no-diagnostics + acc[0] += (int)__builtin_copysignf(1.0f, -0.5f); // expected-no-diagnostics + acc[0] += (int)__builtin_logf(1.0f); // expected-no-diagnostics + acc[0] += (int)__builtin_log(1.0); // expected-no-diagnostics + }); + return 0; +} diff --git a/clang/test/SemaSYCL/unsupported_math.cpp b/clang/test/SemaSYCL/unsupported_math.cpp index 3c0de837dcd77..e0663b708785a 100644 --- a/clang/test/SemaSYCL/unsupported_math.cpp +++ b/clang/test/SemaSYCL/unsupported_math.cpp @@ -1,10 +1,4 @@ // RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -Wno-sycl-2017-compat -verify %s -extern "C" float sinf(float); -extern "C" float cosf(float); -extern "C" float logf(float); -extern "C" double sin(double); -extern "C" double cos(double); -extern "C" double log(double); template __attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) { kernelFunc(); @@ -14,21 +8,9 @@ int main() { kernel([=]() { int acc[1] = {5}; acc[0] *= 2; - acc[0] += (int)sinf(1.0f); // expected-no-error - acc[0] += (int)sin(1.0); // expected-no-error - acc[0] += (int)__builtin_sinf(1.0f); // expected-no-error - acc[0] += (int)__builtin_sin(1.0); // expected-no-error - acc[0] += (int)cosf(1.0f); // expected-no-error - acc[0] += (int)cos(1.0); // expected-no-error - acc[0] += (int)__builtin_cosf(1.0f); // expected-no-error - acc[0] += (int)__builtin_cos(1.0); // expected-no-error - acc[0] += (int)logf(1.0f); // expected-no-error - acc[0] += (int)log(1.0); // expected-no-error - acc[0] += (int)__builtin_logf(1.0f); // expected-no-error - acc[0] += (int)__builtin_log(1.0); // expected-no-error - acc[0] += (int)__builtin_fabsl(-1.0); // expected-error{{builtin is not supported on this target}} - acc[0] += (int)__builtin_cosl(-1.0); // expected-error{{builtin is not supported on this target}} - acc[0] += (int)__builtin_powl(-1.0, 10.0); // expected-error{{builtin is not supported on this target}} + acc[0] += (int)__builtin_fabsl(-1.0); // expected-error{{builtin is not supported on this target}} + acc[0] += (int)__builtin_cosl(-1.0); // expected-error{{builtin is not supported on this target}} + acc[0] += (int)__builtin_powl(-1.0, 10.0); // expected-error{{builtin is not supported on this target}} }); return 0; }