Skip to content

[SYCL] Stop emission of modf intrinsic for NVPTX/AMDGCN #17958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 24, 2025
9 changes: 5 additions & 4 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3154,9 +3154,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
GenerateIntrinsics =
ConstWithoutErrnoOrExceptions && ErrnoOverridenToFalseWithOpt;
}
if (GenerateIntrinsics &&
!(getLangOpts().SYCLIsDevice && (getTarget().getTriple().isNVPTX() ||
getTarget().getTriple().isAMDGCN()))) {
bool IsSYCLDeviceWithoutIntrinsics =
getLangOpts().SYCLIsDevice &&
(getTarget().getTriple().isNVPTX() || getTarget().getTriple().isAMDGCN());
if (GenerateIntrinsics && !IsSYCLDeviceWithoutIntrinsics) {
switch (BuiltinIDIfNoAsmLabel) {
case Builtin::BIacos:
case Builtin::BIacosf:
Expand Down Expand Up @@ -4256,7 +4257,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_modf:
case Builtin::BI__builtin_modff:
case Builtin::BI__builtin_modfl:
if (Builder.getIsFPConstrained())
if (Builder.getIsFPConstrained() || IsSYCLDeviceWithoutIntrinsics)
break; // TODO: Emit constrained modf intrinsic once one exists.
return RValue::get(emitModfBuiltin(*this, E, Intrinsic::modf));
case Builtin::BI__builtin_isgreater:
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/DeviceLib/cmath_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// UNSUPPORTED: true
// UNSUPPORTED: spirv-backend
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17813
// REQUIRES: aspect-fp64
// UNSUPPORTED: target-amd || target-nvidia
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/DeviceLib/cmath_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// UNSUPPORTED: true
// UNSUPPORTED: spirv-backend
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17813
// DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%}

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/DeviceLib/math_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// UNSUPPORTED: true
// UNSUPPORTED: spirv-backend
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17813
// REQUIRES: aspect-fp64

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/DeviceLib/math_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// UNSUPPORTED: true
// UNSUPPORTED: spirv-backend
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17813
// DEFINE: %{mathflags} = %if cl_options %{/clang:-fno-fast-math%} %else %{-fno-fast-math%}

Expand Down