-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RISCV] Add tune info for mem* expansion #118439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So that CPUs can tune these options.
|
@llvm/pr-subscribers-backend-risc-v Author: Pengcheng Wang (wangpc-pp) ChangesSo that CPUs can tune these options. Full diff: https://github.com/llvm/llvm-project/pull/118439.diff 3 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index b2e96b63a80953..8f6e0521b3c1b4 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;
};
|
|
What's your plan for the getters in TargetLowering for the same properties? These are queried elsewhere in the codebase. |
I don't get what you mean, these getters should return the same values that we set in XXXTargetLowering? |
Sorry, I'd somehow missed the part that assigned the underlying values used by those getters in RISCVISelLowering. All good. |
topperc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/9705 Here is the relevant piece of the build log for the reference |
So that CPUs can tune these options.