[libc-commits] [libc] [libc] Coalesce bitfield access in GPU malloc (PR #142692)
Matt Arsenault via libc-commits
libc-commits at lists.llvm.org
Tue Jun 3 16:59:29 PDT 2025
================
@@ -129,6 +129,11 @@ static inline constexpr T round_up(const T x) {
return (x + N) & ~(N - 1);
}
+// Branch free minimum of two integers.
+static inline constexpr uint32_t min(const uint32_t &x, const uint32_t &y) {
+ return y ^ ((x ^ y) & -(x < y));
+}
----------------
arsenm wrote:
This is already a hardware instruction, why not just do the obvious x < y ? x : y? Also why references?
https://github.com/llvm/llvm-project/pull/142692
More information about the libc-commits
mailing list