[llvm] [SDag][ARM][RISCV] Allow lowering CTPOP into a libcall (PR #99752)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 11:19:42 PDT 2024
================
@@ -24,31 +24,14 @@ define signext i32 @ctlz_i32(i32 signext %a) nounwind {
; RV64I-NEXT: srliw a1, a0, 16
; RV64I-NEXT: or a0, a0, a1
; RV64I-NEXT: not a0, a0
-; RV64I-NEXT: srliw a1, a0, 1
-; RV64I-NEXT: lui a2, 349525
-; RV64I-NEXT: addi a2, a2, 1365
-; RV64I-NEXT: and a1, a1, a2
-; RV64I-NEXT: subw a0, a0, a1
-; RV64I-NEXT: lui a1, 209715
-; RV64I-NEXT: addi a1, a1, 819
-; RV64I-NEXT: and a2, a0, a1
-; RV64I-NEXT: srliw a0, a0, 2
-; RV64I-NEXT: and a0, a0, a1
-; RV64I-NEXT: add a0, a2, a0
-; RV64I-NEXT: srliw a1, a0, 4
-; RV64I-NEXT: addw a0, a0, a1
-; RV64I-NEXT: lui a1, 61681
-; RV64I-NEXT: addiw a1, a1, -241
-; RV64I-NEXT: and a0, a0, a1
-; RV64I-NEXT: lui a1, 4112
-; RV64I-NEXT: addiw a1, a1, 257
-; RV64I-NEXT: call __muldi3
-; RV64I-NEXT: srliw a0, a0, 24
+; RV64I-NEXT: call __popcountsi2
; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
; RV64I-NEXT: addi sp, sp, 16
+; RV64I-NEXT: sext.w a0, a0
----------------
topperc wrote:
__popcountsi2 should be returning a sign extended result right?
https://github.com/llvm/llvm-project/pull/99752
More information about the llvm-commits
mailing list