Skip to content

Commit 70b79a9

Browse files
authored
[AMDGPU] Allow the __builtin_flt_rounds functions on AMDGPU (#90994)
Summary: Previous patches added support for the LLVM rounding intrinsic functions. This patch allows them to me emitted using the clang builtins when targeting AMDGPU.
1 parent 2f58b9a commit 70b79a9

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,18 +2533,18 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
25332533
case Builtin::BI_bittestandset64:
25342534
case Builtin::BI_interlockedbittestandreset64:
25352535
case Builtin::BI_interlockedbittestandset64:
2536-
if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
2537-
{llvm::Triple::x86_64, llvm::Triple::arm,
2538-
llvm::Triple::thumb,
2539-
llvm::Triple::aarch64}))
2536+
if (CheckBuiltinTargetInSupported(
2537+
*this, BuiltinID, TheCall,
2538+
{llvm::Triple::x86_64, llvm::Triple::arm, llvm::Triple::thumb,
2539+
llvm::Triple::aarch64, llvm::Triple::amdgcn}))
25402540
return ExprError();
25412541
break;
25422542

25432543
case Builtin::BI__builtin_set_flt_rounds:
2544-
if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
2545-
{llvm::Triple::x86, llvm::Triple::x86_64,
2546-
llvm::Triple::arm, llvm::Triple::thumb,
2547-
llvm::Triple::aarch64}))
2544+
if (CheckBuiltinTargetInSupported(
2545+
*this, BuiltinID, TheCall,
2546+
{llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
2547+
llvm::Triple::thumb, llvm::Triple::aarch64, llvm::Triple::amdgcn}))
25482548
return ExprError();
25492549
break;
25502550

clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,18 @@ unsigned test_wavefrontsize() {
839839
return __builtin_amdgcn_wavefrontsize();
840840
}
841841

842+
// CHECK-LABEL test_flt_rounds(
843+
unsigned test_flt_rounds() {
844+
845+
// CHECK: call i32 @llvm.get.rounding()
846+
unsigned mode = __builtin_flt_rounds();
847+
848+
// CHECK: call void @llvm.set.rounding(i32 %0)
849+
__builtin_set_flt_rounds(mode);
850+
851+
return mode;
852+
}
853+
842854
// CHECK-LABEL test_get_fpenv(
843855
unsigned long test_get_fpenv() {
844856
// CHECK: call i64 @llvm.get.fpenv.i64()

0 commit comments

Comments
 (0)