[llvm] [RISCV] Generalize cost model for vp_fneg. NFC. (PR #126915)
Mikhail R. Gadelha via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 05:59:25 PST 2025
https://github.com/mikhailramalho created https://github.com/llvm/llvm-project/pull/126915
Move the cost model for vp_fneg from the riscv-specific implementation to the generic TTI layer.
This ensures consistent handling of vp_fneg across targets
>From 8927b41fc80b057d9c82c5dd2af09726ab2b3699 Mon Sep 17 00:00:00 2001
From: "Mikhail R. Gadelha" <mikhail at igalia.com>
Date: Wed, 12 Feb 2025 10:53:03 -0300
Subject: [PATCH] [RISCV] Generalize cost model for vp_fneg. NFC.
Move the cost model for vp_fneg from the riscv-specific implementation to the
generic TTI layer. This ensures consistent handling of vp_fneg across targets
---
llvm/include/llvm/CodeGen/BasicTTIImpl.h | 3 ++-
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | 7 -------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 8468992ed4b7a..30c24494e3995 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1675,7 +1675,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return thisT()->getMemoryOpCost(*FOp, ICA.getArgTypes()[0], Alignment,
AS, CostKind);
}
- if (VPBinOpIntrinsic::isVPBinOp(ICA.getID())) {
+ if (VPBinOpIntrinsic::isVPBinOp(ICA.getID()) ||
+ ICA.getID() == Intrinsic::vp_fneg) {
return thisT()->getArithmeticInstrCost(*FOp, ICA.getReturnType(),
CostKind);
}
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index c46400a1936ad..da77bae18962c 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1356,13 +1356,6 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return Cost * LT.first;
break;
}
- case Intrinsic::vp_fneg: {
- std::optional<unsigned> FOp =
- VPIntrinsic::getFunctionalOpcodeForVP(ICA.getID());
- assert(FOp.has_value());
- return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
- break;
- }
case Intrinsic::vp_select: {
Intrinsic::ID IID = ICA.getID();
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
More information about the llvm-commits
mailing list