[llvm-branch-commits] [llvm] [BPF] expand cttz, ctlz for i32, i64 (PR #73668)

Yingchi Long via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 31 17:08:42 PST 2024


================
@@ -0,0 +1,304 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
+; RUN: llc < %s -march=bpf | FileCheck %s
+
+; test that we can expand CTTZ & CTLZ
+
+declare i32 @llvm.cttz.i32(i32, i1)
+
+define i32 @cttz_i32_zdef(i32 %a) {
+; CHECK-LABEL: cttz_i32_zdef:
----------------
inclyc wrote:

> Question, how stable are these expansions?

It is expanded by common codegen functions, thus might be changed without modifications in BPF backend.

> Previously compiler would just error out, maybe just insert some dummy checks that verify that something is returned from these functions? 

I think for compilers "CodeGen" tests, it is common to assert "Generated Asm" without actually run it. For example, for aarch64 backend developers, a "trick" is to write some code on x86 machine, testing the assembly without aarch64 emulator(e.g. qemu-user). 

So IMHO, for LLVM codegen we can just `CHECK-NEXT`: these asm lines. (They can be automatically generated)

> And we can add a few tests on kernel side that verify runtime result.

Yes, that would be nice if we can test "runtime" behavior.

https://github.com/llvm/llvm-project/pull/73668


More information about the llvm-branch-commits mailing list