Skip to content

Commit 5153ba3

Browse files
committed
[AMDGPU] Allow w64 ballot to be used on w32 targets
Summary: Currently we cannot compile `__builtin_amdgcn_ballot_w64` on non-wave64 targets even though it is valid. This is relevant for making library code that can handle both without needing to check the wavefront size. This patch relaxes the semantic check for w64 so it can be used normally.
1 parent 2542876 commit 5153ba3

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiWUiUiV4Ui", "nc")
151151
//===----------------------------------------------------------------------===//
152152

153153
TARGET_BUILTIN(__builtin_amdgcn_ballot_w32, "ZUib", "nc", "wavefrontsize32")
154-
TARGET_BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc", "wavefrontsize64")
154+
BUILTIN(__builtin_amdgcn_ballot_w64, "WUib", "nc")
155155

156156
// Deprecated intrinsics in favor of __builtin_amdgn_ballot_{w32|w64}
157157
BUILTIN(__builtin_amdgcn_uicmp, "WUiUiUiIi", "nc")

clang/test/SemaOpenCL/builtins-amdgcn-error-wave64.cl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -target-feature -wavefrontsize64 -verify -S -o - %s
55
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1010 -verify -S -o - %s
66

7+
// expected-no-diagnostics
8+
79
typedef unsigned long ulong;
810

911
void test_ballot_wave64(global ulong* out, int a, int b) {
10-
*out = __builtin_amdgcn_ballot_w64(a == b); // expected-error {{'__builtin_amdgcn_ballot_w64' needs target feature wavefrontsize64}}
11-
}
12-
13-
__attribute__((target("wavefrontsize64")))
14-
void test_ballot_wave64_target_attr(global ulong* out, int a, int b) {
1512
*out = __builtin_amdgcn_ballot_w64(a == b);
1613
}

0 commit comments

Comments
 (0)