[llvm-branch-commits] [llvm] [BPF] expand cttz, ctlz for i32, i64 (PR #73668)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 31 06:09:15 PST 2024
eddyz87 wrote:
I tried this with the test below using current kernel master, and all works as expected.
```diff
diff --git a/tools/testing/selftests/bpf/progs/verifier_and.c b/tools/testing/selftests/bpf/progs/verifier_and.c
index e97e518516b6..8a051bd0c886 100644
--- a/tools/testing/selftests/bpf/progs/verifier_and.c
+++ b/tools/testing/selftests/bpf/progs/verifier_and.c
@@ -104,4 +104,14 @@ l0_%=: r0 = 0; \
: __clobber_all);
}
+unsigned A[3] = {1u << 31, 1u << 30, 1u << 29};
+
+SEC("socket") __success __retval(0) int clz1(void *ctx) { return __builtin_clz(A[0]); }
+SEC("socket") __success __retval(1) int clz2(void *ctx) { return __builtin_clz(A[1]); }
+SEC("socket") __success __retval(2) int clz3(void *ctx) { return __builtin_clz(A[2]); }
+
+SEC("socket") __success __retval(31) int ctz1(void *ctx) { return __builtin_ctz(A[0]); }
+SEC("socket") __success __retval(30) int ctz2(void *ctx) { return __builtin_ctz(A[1]); }
+SEC("socket") __success __retval(29) int ctz3(void *ctx) { return __builtin_ctz(A[2]); }
+
char _license[] SEC("license") = "GPL";
```
https://github.com/llvm/llvm-project/pull/73668
More information about the llvm-branch-commits
mailing list