[libc-commits] [libc] [libc] Use __builtin_ffsll for RPC lane mask (PR #85000)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Tue Mar 12 17:16:16 PDT 2024


https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/85000

src/__support/GPU/utils.h doesn't compile on a 32-bit platforms because __builtin_ffsl uses long which is a 32-bit number. Use __builtin_ffsll which uses long long which is guaranteed to be at least 64-bits.

>From 22b481793e8dca7a24787fcbdf2ce2194c696d6d Mon Sep 17 00:00:00 2001
From: Petr Hosek <phosek at google.com>
Date: Tue, 12 Mar 2024 17:14:36 -0700
Subject: [PATCH] [libc] Use __builtin_ffsll for RPC lane mask

src/__support/GPU/utils.h doesn't compile on a 32-bit platforms because
__builtin_ffsl uses long which is a 32-bit number. Use __builtin_ffsll
which uses long long which is guaranteed to be at least 64-bits.
---
 libc/src/__support/GPU/utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/src/__support/GPU/utils.h b/libc/src/__support/GPU/utils.h
index 0f9167cdee0663..45523f88f917f7 100644
--- a/libc/src/__support/GPU/utils.h
+++ b/libc/src/__support/GPU/utils.h
@@ -23,7 +23,7 @@ namespace LIBC_NAMESPACE {
 namespace gpu {
 /// Get the first active thread inside the lane.
 LIBC_INLINE uint64_t get_first_lane_id(uint64_t lane_mask) {
-  return __builtin_ffsl(lane_mask) - 1;
+  return __builtin_ffsll(lane_mask) - 1;
 }
 
 /// Conditional that is only true for a single thread in a lane.



More information about the libc-commits mailing list