Skip to content

[AMDGPU] Allow the __builtin_flt_rounds functions on AMDGPU #90994

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 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2535,18 +2535,18 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
case Builtin::BI_bittestandset64:
case Builtin::BI_interlockedbittestandreset64:
case Builtin::BI_interlockedbittestandset64:
if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
{llvm::Triple::x86_64, llvm::Triple::arm,
llvm::Triple::thumb,
llvm::Triple::aarch64}))
if (CheckBuiltinTargetInSupported(
*this, BuiltinID, TheCall,
{llvm::Triple::x86_64, llvm::Triple::arm, llvm::Triple::thumb,
llvm::Triple::aarch64, llvm::Triple::amdgcn}))
return ExprError();
break;

case Builtin::BI__builtin_set_flt_rounds:
if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
{llvm::Triple::x86, llvm::Triple::x86_64,
llvm::Triple::arm, llvm::Triple::thumb,
llvm::Triple::aarch64}))
if (CheckBuiltinTargetInSupported(
*this, BuiltinID, TheCall,
{llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
llvm::Triple::thumb, llvm::Triple::aarch64, llvm::Triple::amdgcn}))
return ExprError();
break;

Expand Down
12 changes: 12 additions & 0 deletions clang/test/CodeGenOpenCL/builtins-amdgcn.cl
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,18 @@ unsigned test_wavefrontsize() {
return __builtin_amdgcn_wavefrontsize();
}

// CHECK-LABEL test_flt_rounds(
unsigned test_flt_rounds() {

// CHECK: call i32 @llvm.get.rounding()
unsigned mode = __builtin_flt_rounds();

// CHECK: call void @llvm.set.rounding(i32 %0)
__builtin_set_flt_rounds(mode);

return mode;
}

// CHECK-LABEL test_get_fpenv(
unsigned long test_get_fpenv() {
// CHECK: call i64 @llvm.get.fpenv.i64()
Expand Down