[llvm] d106a39 - [AArch64] Minor cleanup and speedup for getVectorInstrCostHelper
David Green via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 28 17:11:44 PST 2024
Author: David Green
Date: 2024-11-29T01:11:39Z
New Revision: d106a39c3372b924668f203fedbce69aa986cf50
URL: https://github.com/llvm/llvm-project/commit/d106a39c3372b924668f203fedbce69aa986cf50
DIFF: https://github.com/llvm/llvm-project/commit/d106a39c3372b924668f203fedbce69aa986cf50.diff
LOG: [AArch64] Minor cleanup and speedup for getVectorInstrCostHelper
If UserToExtractIdx is empty then we can skip checking the users.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 7a1e401bca18cb..a415ab4c7f7dbc 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -3248,15 +3248,14 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
// Check if the extractelement user is scalar fmul.
auto IsUserFMulScalarTy = [](const Value *EEUser) {
// Check if the user is scalar fmul.
- const auto *BO = dyn_cast_if_present<BinaryOperator>(EEUser);
+ const auto *BO = dyn_cast<BinaryOperator>(EEUser);
return BO && BO->getOpcode() == BinaryOperator::FMul &&
!BO->getType()->isVectorTy();
};
// Check if the extract index is from lane 0 or lane equivalent to 0 for a
// certain scalar type and a certain vector register width.
- auto IsExtractLaneEquivalentToZero = [&](const unsigned &Idx,
- const unsigned &EltSz) {
+ auto IsExtractLaneEquivalentToZero = [&](unsigned Idx, unsigned EltSz) {
auto RegWidth =
getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector)
.getFixedValue();
@@ -3277,13 +3276,15 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
// important.
UserToExtractIdx[U];
}
+ if (UserToExtractIdx.empty())
+ return false;
for (auto &[S, U, L] : ScalarUserAndIdx) {
for (auto *U : S->users()) {
if (UserToExtractIdx.find(U) != UserToExtractIdx.end()) {
auto *FMul = cast<BinaryOperator>(U);
auto *Op0 = FMul->getOperand(0);
auto *Op1 = FMul->getOperand(1);
- if ((Op0 == S && Op1 == S) || (Op0 != S) || (Op1 != S)) {
+ if ((Op0 == S && Op1 == S) || Op0 != S || Op1 != S) {
UserToExtractIdx[U] = L;
break;
}
More information about the llvm-commits
mailing list