[llvm] [AArch64] Add costs for ROTR and ROTL. (PR #169335)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 24 09:09:54 PST 2025
================
@@ -921,8 +921,19 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
if (ICA.getArgs().empty())
break;
- // TODO: Add handling for fshl where third argument is not a constant.
const TTI::OperandValueInfo OpInfoZ = TTI::getOperandInfo(ICA.getArgs()[2]);
+
+ // ROTR / ROTL on integer registers can be done in a single instruction. A
+ // fshl with a non-constant shift uses a neg + ror.
+ if (RetTy->isIntegerTy() && ICA.getArgs()[0] == ICA.getArgs()[1] &&
+ (RetTy->getPrimitiveSizeInBits() == 32 ||
+ RetTy->getPrimitiveSizeInBits() == 64)) {
+ InstructionCost NegCost =
+ (ICA.getID() == Intrinsic::fshl && !OpInfoZ.isConstant()) ? 1 : 0;
+ return 1 + NegCost;
----------------
MDevereau wrote:
Can you just do
```suggestion
return 1 + (ICA.getID() == Intrinsic::fshl && !OpInfoZ.isConstant());
```
?
https://github.com/llvm/llvm-project/pull/169335
More information about the llvm-commits
mailing list