[llvm] 35619c7 - [RISCV] Add tune info for mem* expansion (#118439)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 22:48:40 PST 2024
Author: Pengcheng Wang
Date: 2024-12-06T14:48:37+08:00
New Revision: 35619c791d1f5128d16c7a8e099e8856e12ab39c
URL: https://github.com/llvm/llvm-project/commit/35619c791d1f5128d16c7a8e099e8856e12ab39c
DIFF: https://github.com/llvm/llvm-project/commit/35619c791d1f5128d16c7a8e099e8856e12ab39c.diff
LOG: [RISCV] Add tune info for mem* expansion (#118439)
So that CPUs can tune these options.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVProcessors.td
llvm/lib/Target/RISCV/RISCVSubtarget.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 004dbcb7a09682..37445d990eca20 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1544,6 +1544,20 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
// corresponding branch. This information is used in CGP/SelectOpt to decide
// when to convert selects into branches.
PredictableSelectIsExpensive = Subtarget.predictableSelectIsExpensive();
+
+ MaxStoresPerMemsetOptSize = Subtarget.getMaxStoresPerMemset(/*OptSize=*/true);
+ MaxStoresPerMemset = Subtarget.getMaxStoresPerMemset(/*OptSize=*/false);
+
+ MaxGluedStoresPerMemcpy = Subtarget.getMaxGluedStoresPerMemcpy();
+ MaxStoresPerMemcpyOptSize = Subtarget.getMaxStoresPerMemcpy(/*OptSize=*/true);
+ MaxStoresPerMemcpy = Subtarget.getMaxStoresPerMemcpy(/*OptSize=*/false);
+
+ MaxStoresPerMemmoveOptSize =
+ Subtarget.getMaxStoresPerMemmove(/*OptSize=*/true);
+ MaxStoresPerMemmove = Subtarget.getMaxStoresPerMemmove(/*OptSize=*/false);
+
+ MaxLoadsPerMemcmpOptSize = Subtarget.getMaxLoadsPerMemcmp(/*OptSize=*/true);
+ MaxLoadsPerMemcmp = Subtarget.getMaxLoadsPerMemcmp(/*OptSize=*/false);
}
EVT RISCVTargetLowering::getSetCCResultType(const DataLayout &DL,
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 471f051728e99f..c4e19c515b155b 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -24,15 +24,32 @@ class RISCVTuneInfo {
// Tail duplication threshold at -O3.
bits<32> TailDupAggressiveThreshold = 6;
+
+ bits<32> MaxStoresPerMemsetOptSize = 4;
+ bits<32> MaxStoresPerMemset = 8;
+
+ bits<32> MaxGluedStoresPerMemcpy = 0;
+ bits<32> MaxStoresPerMemcpyOptSize = 4;
+ bits<32> MaxStoresPerMemcpy = 8;
+
+ bits<32> MaxStoresPerMemmoveOptSize = 4;
+ bits<32> MaxStoresPerMemmove = 8;
+
+ bits<32> MaxLoadsPerMemcmpOptSize = 4;
+ bits<32> MaxLoadsPerMemcmp = 8;
}
def RISCVTuneInfoTable : GenericTable {
let FilterClass = "RISCVTuneInfo";
let CppTypeName = "RISCVTuneInfo";
let Fields = ["Name", "PrefFunctionAlignment", "PrefLoopAlignment",
- "CacheLineSize", "PrefetchDistance",
- "MinPrefetchStride", "MaxPrefetchIterationsAhead",
- "MinimumJumpTableEntries", "TailDupAggressiveThreshold"];
+ "CacheLineSize", "PrefetchDistance", "MinPrefetchStride",
+ "MaxPrefetchIterationsAhead", "MinimumJumpTableEntries",
+ "TailDupAggressiveThreshold", "MaxStoresPerMemsetOptSize",
+ "MaxStoresPerMemset", "MaxGluedStoresPerMemcpy",
+ "MaxStoresPerMemcpyOptSize", "MaxStoresPerMemcpy",
+ "MaxStoresPerMemmoveOptSize", "MaxStoresPerMemmove",
+ "MaxLoadsPerMemcmpOptSize", "MaxLoadsPerMemcmp"];
}
def getRISCVTuneInfo : SearchIndex {
diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h
index 043838e13b964d..feed84c68a7869 100644
--- a/llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h
@@ -53,6 +53,19 @@ struct RISCVTuneInfo {
// Tail duplication threshold at -O3.
unsigned TailDupAggressiveThreshold;
+
+ unsigned MaxStoresPerMemsetOptSize;
+ unsigned MaxStoresPerMemset;
+
+ unsigned MaxGluedStoresPerMemcpy;
+ unsigned MaxStoresPerMemcpyOptSize;
+ unsigned MaxStoresPerMemcpy;
+
+ unsigned MaxStoresPerMemmoveOptSize;
+ unsigned MaxStoresPerMemmove;
+
+ unsigned MaxLoadsPerMemcmpOptSize;
+ unsigned MaxLoadsPerMemcmp;
};
#define GET_RISCVTuneInfoTable_DECL
@@ -325,6 +338,30 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
return TuneInfo->TailDupAggressiveThreshold;
}
+ unsigned getMaxStoresPerMemset(bool OptSize) const {
+ return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
+ : TuneInfo->MaxStoresPerMemset;
+ }
+
+ unsigned getMaxGluedStoresPerMemcpy() const {
+ return TuneInfo->MaxGluedStoresPerMemcpy;
+ }
+
+ unsigned getMaxStoresPerMemcpy(bool OptSize) const {
+ return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
+ : TuneInfo->MaxStoresPerMemcpy;
+ }
+
+ unsigned getMaxStoresPerMemmove(bool OptSize) const {
+ return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
+ : TuneInfo->MaxStoresPerMemmove;
+ }
+
+ unsigned getMaxLoadsPerMemcmp(bool OptSize) const {
+ return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
+ : TuneInfo->MaxLoadsPerMemcmp;
+ }
+
void overrideSchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const override;
};
More information about the llvm-commits
mailing list