Write a log(n) fallback for llvm_vector_reduce_add

This may be what LLVM does at any rate
This commit is contained in:
gingerBill
2021-10-28 15:01:13 +01:00
parent 70793236ab
commit 3794d2417d
2 changed files with 72 additions and 6 deletions

View File

@@ -443,7 +443,17 @@ u64 ceil_log2(u64 x) {
return cast(u64)(bit_set_count(x) - 1 - y);
}
u32 prev_pow2(u32 n) {
if (n == 0) {
return 0;
}
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
return n - (n >> 1);
}
i32 prev_pow2(i32 n) {
if (n <= 0) {
return 0;