Skip to content

Commit

Permalink
[clang][AMDGPU] fix the return type for ballot (#73906)
Browse files Browse the repository at this point in the history
In the builtins declaration, "ULi" is a 32-bit integer on Windows. Use
"WUi" instead to ensure a 64-bit integer on all platforms.
  • Loading branch information
ssahasra committed Dec 4, 2023
1 parent c1140d4 commit 9db6423
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/BuiltinsAMDGPU.def
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
// Ballot builtins.
//===----------------------------------------------------------------------===//

TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "Uib", "nc", "wavefrontsize32")
TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "LUib", "nc", "wavefrontsize64")
TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "ZUib", "nc", "wavefrontsize32")
TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc", "wavefrontsize64")

// Deprecated intrinsics in favor of __builtin_amdgn_ballot_{w32|w64}
BUILTIN(__builtin_amdgcn_uicmp, "WUiUiUiIi", "nc")
Expand Down
6 changes: 0 additions & 6 deletions clang/test/CodeGenHIP/ballot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// REQUIRES: amdgpu-registered-target
// XFAIL: *
// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -target-cpu gfx900 -x hip -S -fcuda-is-device -o - %s | FileCheck %s --check-prefix=GFX9

Expand All @@ -9,11 +8,6 @@
// cross-compiles to Windows to confirm that the return type is indeed 64 bits
// on Windows.

// FIXME: The Clang declaration of the wave-64 builtin uses "UL" as the return
// type, which is interpreted as a 32-bit unsigned integer on Windows. This
// emits an incorrect LLVM declaration with i32 return type instead of i64. The
// clang declaration needs to be fixed to use "WU" instead.

// CHECK-LABEL: @_Z3fooi
// CHECK: call i64 @llvm.amdgcn.ballot.i64

Expand Down

0 comments on commit 9db6423

Please sign in to comment.