|
16 | 16 | #include "RISCV.h"
|
17 | 17 | #include "RISCVFrameLowering.h"
|
18 | 18 | #include "RISCVTargetMachine.h"
|
| 19 | +#include "llvm/CodeGen/MachineScheduler.h" |
19 | 20 | #include "llvm/CodeGen/MacroFusion.h"
|
20 | 21 | #include "llvm/CodeGen/ScheduleDAGMutation.h"
|
21 | 22 | #include "llvm/MC/TargetRegistry.h"
|
@@ -199,3 +200,25 @@ unsigned RISCVSubtarget::getMinimumJumpTableEntries() const {
|
199 | 200 | ? RISCVMinimumJumpTableEntries
|
200 | 201 | : TuneInfo->MinimumJumpTableEntries;
|
201 | 202 | }
|
| 203 | + |
| 204 | +void RISCVSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy, |
| 205 | + unsigned NumRegionInstrs) const { |
| 206 | + // Do bidirectional scheduling since it provides a more balanced scheduling |
| 207 | + // leading to better performance. This will increase compile time. |
| 208 | + Policy.OnlyTopDown = false; |
| 209 | + Policy.OnlyBottomUp = false; |
| 210 | + |
| 211 | + // Enabling or Disabling the latency heuristic is a close call: It seems to |
| 212 | + // help nearly no benchmark on out-of-order architectures, on the other hand |
| 213 | + // it regresses register pressure on a few benchmarking. |
| 214 | + // FIXME: This is from AArch64, but we haven't evaluated it on RISC-V. |
| 215 | + Policy.DisableLatencyHeuristic = true; |
| 216 | + |
| 217 | + // Spilling is generally expensive on all RISC-V cores, so always enable |
| 218 | + // register-pressure tracking. This will increase compile time. |
| 219 | + Policy.ShouldTrackPressure = true; |
| 220 | + |
| 221 | + // Enabling ShouldTrackLaneMasks when vector instructions are supported. |
| 222 | + // TODO: Add extensions that need register pairs as well? |
| 223 | + Policy.ShouldTrackLaneMasks = hasVInstructions(); |
| 224 | +} |
0 commit comments