[llvm-branch-commits] [llvm] [SPARC] Use lzcnt to implement CTLZ when we have VIS3 (PR #135715)

Sergei Barannikov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 16 18:43:19 PDT 2025


================
@@ -0,0 +1,183 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=sparcv9 | FileCheck %s -check-prefix=V9
+; RUN: llc < %s -mtriple=sparcv9 -mattr=popc | FileCheck %s -check-prefix=POPC
+; RUN: llc < %s -mtriple=sparcv9 -mattr=vis3 | FileCheck %s -check-prefix=VIS3
+
+define i32 @i32_nopoison(i32 %x) nounwind {
+; V9-LABEL: i32_nopoison:
+; V9:       ! %bb.0:
+; V9-NEXT:    save %sp, -176, %sp
+; V9-NEXT:    cmp %i0, 0
+; V9-NEXT:    be %icc, .LBB0_2
+; V9-NEXT:    nop
+; V9-NEXT:  ! %bb.1: ! %cond.false
+; V9-NEXT:    call __clzdi2
+; V9-NEXT:    sllx %i0, 32, %o0
+; V9-NEXT:    ret
+; V9-NEXT:    restore %g0, %o0, %o0
+; V9-NEXT:  .LBB0_2:
+; V9-NEXT:    ret
+; V9-NEXT:    restore %g0, 32, %o0
+;
+; POPC-LABEL: i32_nopoison:
+; POPC:       ! %bb.0:
+; POPC-NEXT:    cmp %o0, 0
+; POPC-NEXT:    be %icc, .LBB0_2
+; POPC-NEXT:    nop
+; POPC-NEXT:  ! %bb.1: ! %cond.false
+; POPC-NEXT:    srl %o0, 1, %o1
+; POPC-NEXT:    or %o0, %o1, %o0
+; POPC-NEXT:    srl %o0, 2, %o1
+; POPC-NEXT:    or %o0, %o1, %o0
+; POPC-NEXT:    srl %o0, 4, %o1
+; POPC-NEXT:    or %o0, %o1, %o0
+; POPC-NEXT:    srl %o0, 8, %o1
+; POPC-NEXT:    or %o0, %o1, %o0
+; POPC-NEXT:    srl %o0, 16, %o1
+; POPC-NEXT:    or %o0, %o1, %o0
+; POPC-NEXT:    xor %o0, -1, %o0
+; POPC-NEXT:    srl %o0, 0, %o0
+; POPC-NEXT:    retl
+; POPC-NEXT:    popc %o0, %o0
+; POPC-NEXT:  .LBB0_2:
+; POPC-NEXT:    retl
+; POPC-NEXT:    mov 32, %o0
+;
+; VIS3-LABEL: i32_nopoison:
+; VIS3:       ! %bb.0:
+; VIS3-NEXT:    cmp %o0, 0
+; VIS3-NEXT:    be %icc, .LBB0_2
----------------
s-barannikov wrote:

The branch is redundant, but I guess there is nothing we can do with it right now. It must've been created too early.


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


More information about the llvm-branch-commits mailing list