[llvm] [RISCV][TTI] Add cost model for ROTL/ROTR (PR #170824)

Sudharsan Veeravalli via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 09:22:18 PST 2025


================
@@ -1559,6 +1559,20 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
     }
     break;
   }
+  case Intrinsic::fshl:
+  case Intrinsic::fshr: {
+    // Funnel-shifts are ROTL/ROTR when the first and second operand are equal.
+    // When Zbb/Zbkb is enabled we can use a single ROL(W)/ROR(I)(W)
+    // instruction.
+    if ((ST->hasStdExtZbb() || ST->hasStdExtZbkb()) && RetTy->isIntegerTy() &&
+        ICA.getArgs()[0] == ICA.getArgs()[1] &&
+        (RetTy->getPrimitiveSizeInBits() == 32 ||
----------------
svs-quic wrote:

Done

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


More information about the llvm-commits mailing list