Skip to content

Commit f7e99ad

Browse files
committed
Add TailDupAggressiveThreshold to RISCVTuneInfo
1 parent 8c63d85 commit f7e99ad

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,9 +3763,10 @@ RISCVInstrInfo::getSerializableMachineMemOperandTargetFlags() const {
37633763
return ArrayRef(TargetFlags);
37643764
}
37653765

3766-
unsigned int
3767-
RISCVInstrInfo::getTailDuplicateSize(CodeGenOptLevel OptLevel) const {
3768-
return OptLevel >= CodeGenOptLevel::Aggressive ? 6 : 2;
3766+
unsigned RISCVInstrInfo::getTailDuplicateSize(CodeGenOptLevel OptLevel) const {
3767+
return OptLevel >= CodeGenOptLevel::Aggressive
3768+
? STI.getTailDupAggressiveThreshold()
3769+
: 2;
37693770
}
37703771

37713772
// Returns true if this is the sext.w pattern, addiw rd, rs1, 0.

llvm/lib/Target/RISCV/RISCVInstrInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class RISCVInstrInfo : public RISCVGenInstrInfo {
288288
ArrayRef<std::pair<MachineMemOperand::Flags, const char *>>
289289
getSerializableMachineMemOperandTargetFlags() const override;
290290

291-
unsigned int getTailDuplicateSize(CodeGenOptLevel OptLevel) const override;
291+
unsigned getTailDuplicateSize(CodeGenOptLevel OptLevel) const override;
292292

293293
unsigned getUndefInitOpcode(unsigned RegClassID) const override {
294294
switch (RegClassID) {

llvm/lib/Target/RISCV/RISCVProcessors.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class RISCVTuneInfo {
2121
bits<32> MaxPrefetchIterationsAhead = -1;
2222

2323
bits<32> MinimumJumpTableEntries = 5;
24+
25+
// Tail duplication threshold at -O3.
26+
bits<32> TailDupAggressiveThreshold = 6;
2427
}
2528

2629
def RISCVTuneInfoTable : GenericTable {
@@ -29,7 +32,7 @@ def RISCVTuneInfoTable : GenericTable {
2932
let Fields = ["Name", "PrefFunctionAlignment", "PrefLoopAlignment",
3033
"CacheLineSize", "PrefetchDistance",
3134
"MinPrefetchStride", "MaxPrefetchIterationsAhead",
32-
"MinimumJumpTableEntries"];
35+
"MinimumJumpTableEntries", "TailDupAggressiveThreshold"];
3336
}
3437

3538
def getRISCVTuneInfo : SearchIndex {

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ struct RISCVTuneInfo {
5050
unsigned MaxPrefetchIterationsAhead;
5151

5252
unsigned MinimumJumpTableEntries;
53+
54+
// Tail duplication threshold at -O3.
55+
unsigned TailDupAggressiveThreshold;
5356
};
5457

5558
#define GET_RISCVTuneInfoTable_DECL
@@ -300,6 +303,10 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
300303

301304
unsigned getMinimumJumpTableEntries() const;
302305

306+
unsigned getTailDupAggressiveThreshold() const {
307+
return TuneInfo->TailDupAggressiveThreshold;
308+
}
309+
303310
bool supportsInitUndef() const override { return hasVInstructions(); }
304311
};
305312
} // End llvm namespace

0 commit comments

Comments
 (0)