[llvm] [RISCV] Provide a more efficient lowering for experimental.cttz.elts. (PR #88552)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 08:33:24 PDT 2024


================
@@ -1484,6 +1484,11 @@ bool RISCVTargetLowering::shouldExpandGetVectorLength(EVT TripCountVT,
   return VF > MaxVF || !isPowerOf2_32(VF);
 }
 
+bool RISCVTargetLowering::shouldExpandCttzElements(EVT VT) const {
+  return !Subtarget.hasVInstructions() ||
+         VT.getVectorElementType() != MVT::i1 || !isTypeLegal(VT);
----------------
preames wrote:

We could handle the legal non-i1 case via s simple vector comparison against zero - producing a mask result that then flows through this code.  From the tests, this looks like a pretty huge improvement in codegen quality.  

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


More information about the llvm-commits mailing list