From 70ff18a4631d5e59ff50de625152bcce787c8fb7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Jul 2023 10:53:16 -0700 Subject: [PATCH] riscv: Implement count leading zeros. --- Core/MIPS/RiscV/RiscVCompALU.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/MIPS/RiscV/RiscVCompALU.cpp b/Core/MIPS/RiscV/RiscVCompALU.cpp index aa3197dbf1..1b29413797 100644 --- a/Core/MIPS/RiscV/RiscVCompALU.cpp +++ b/Core/MIPS/RiscV/RiscVCompALU.cpp @@ -254,7 +254,13 @@ void RiscVJit::CompIR_Bits(IRInst inst) { break; case IROp::Clz: - CompIR_Generic(inst); + if (cpu_info.RiscV_Zbb) { + gpr.MapDirtyIn(inst.dest, inst.src1, MapType::AVOID_LOAD_MARK_NORM32); + // This even sets to 32 when zero, perfect. + CLZW(gpr.R(inst.dest), gpr.R(inst.src1)); + } else { + CompIR_Generic(inst); + } break; default: