[PATCH] D129072: [NFC][RISCV] Make the cost calculation of getIntMatCost more clear
Zixuan Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 02:37:27 PDT 2022
zixuan-wu updated this revision to Diff 442481.
zixuan-wu retitled this revision from "[RISCV] Fix the scale of getIntMatCost and also need adjust for getIntImmCost" to "[NFC][RISCV] Make the cost calculation of getIntMatCost more clear".
zixuan-wu edited the summary of this revision.
zixuan-wu added a comment.
The logic of getIntMatCost and getInstSeqCost is correct to be called in different code place. But the logic is not clear.
So make it clear without still constructing 2 different version of getIntMatCost to reuse the for loop to calculate cost of each chunk.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129072/new/
https://reviews.llvm.org/D129072
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
@@ -14,7 +14,7 @@
static int getInstSeqCost(RISCVMatInt::InstSeq &Res, bool HasRVC) {
if (!HasRVC)
- return Res.size();
+ return Res.size() * 100;
int Cost = 0;
for (auto Instr : Res) {
@@ -381,7 +381,7 @@
int getIntMatCost(const APInt &Val, unsigned Size,
const FeatureBitset &ActiveFeatures, bool CompressionCost) {
bool IsRV64 = ActiveFeatures[RISCV::Feature64Bit];
- bool HasRVC = CompressionCost && ActiveFeatures[RISCV::FeatureStdExtC];
+ bool HasRVC = ActiveFeatures[RISCV::FeatureStdExtC];
int PlatRegSize = IsRV64 ? 64 : 32;
// Split the constant into platform register sized chunks, and calculate cost
@@ -390,9 +390,16 @@
for (unsigned ShiftVal = 0; ShiftVal < Size; ShiftVal += PlatRegSize) {
APInt Chunk = Val.ashr(ShiftVal).sextOrTrunc(PlatRegSize);
InstSeq MatSeq = generateInstSeq(Chunk.getSExtValue(), ActiveFeatures);
- Cost += getInstSeqCost(MatSeq, HasRVC);
+ if (CompressionCost)
+ Cost += getInstSeqCost(MatSeq, HasRVC);
+ else
+ Cost += MatSeq.size();
}
- return std::max(1, Cost);
+
+ if (CompressionCost)
+ return Cost;
+ else
+ return std::max(1, Cost);
}
OpndKind Inst::getOpndKind() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129072.442481.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220706/f051602e/attachment.bin>
More information about the llvm-commits
mailing list