diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td --- a/llvm/lib/Target/RISCV/RISCV.td +++ b/llvm/lib/Target/RISCV/RISCV.td @@ -430,6 +430,10 @@ def FeatureSaveRestore : SubtargetFeature<"save-restore", "EnableSaveRestore", "true", "Enable save/restore.">; +def TuneNoDefaultUnroll + : SubtargetFeature<"no-default-unroll", "EnableDefaultUnroll", "false", + "Disable default unroll preference.">; + def TuneSiFive7 : SubtargetFeature<"sifive7", "RISCVProcFamily", "SiFive7", "SiFive 7-Series processors">; @@ -465,9 +469,9 @@ def : ProcessorModel<"rocket-rv64", RocketModel, [Feature64Bit]>; def : ProcessorModel<"sifive-7-rv32", SiFive7Model, [], - [TuneSiFive7]>; + [TuneSiFive7, TuneNoDefaultUnroll]>; def : ProcessorModel<"sifive-7-rv64", SiFive7Model, [Feature64Bit], - [TuneSiFive7]>; + [TuneSiFive7, TuneNoDefaultUnroll]>; def : ProcessorModel<"sifive-e20", RocketModel, [FeatureStdExtM, FeatureStdExtC]>; @@ -494,7 +498,7 @@ FeatureStdExtA, FeatureStdExtF, FeatureStdExtC], - [TuneSiFive7]>; + [TuneSiFive7, TuneNoDefaultUnroll]>; def : ProcessorModel<"sifive-s21", RocketModel, [Feature64Bit, FeatureStdExtM, @@ -519,7 +523,7 @@ FeatureStdExtF, FeatureStdExtD, FeatureStdExtC], - [TuneSiFive7]>; + [TuneSiFive7, TuneNoDefaultUnroll]>; def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit, FeatureStdExtM, @@ -534,7 +538,7 @@ FeatureStdExtF, FeatureStdExtD, FeatureStdExtC], - [TuneSiFive7]>; + [TuneSiFive7, TuneNoDefaultUnroll]>; //===----------------------------------------------------------------------===// // Define the RISC-V target. diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h @@ -90,6 +90,7 @@ bool IsRV32E = false; bool EnableLinkerRelax = false; bool EnableRVCHintInstrs = true; + bool EnableDefaultUnroll = true; bool EnableSaveRestore = false; unsigned XLen = 32; unsigned ZvlLen = 0; @@ -179,6 +180,7 @@ bool isRV32E() const { return IsRV32E; } bool enableLinkerRelax() const { return EnableLinkerRelax; } bool enableRVCHintInstrs() const { return EnableRVCHintInstrs; } + bool enableDefaultUnroll() const { return EnableDefaultUnroll; } bool enableSaveRestore() const { return EnableSaveRestore; } MVT getXLenVT() const { return XLenVT; } unsigned getXLen() const { return XLen; } diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -352,13 +352,8 @@ // TODO: More tuning on benchmarks and metrics with changes as needed // would apply to all settings below to enable performance. - // Support explicit targets enabled for SiFive with the unrolling preferences - // below - bool UseDefaultPreferences = true; - if (ST->getProcFamily() == RISCVSubtarget::SiFive7) - UseDefaultPreferences = false; - if (UseDefaultPreferences) + if (ST->enableDefaultUnroll()) return BasicTTIImplBase::getUnrollingPreferences(L, SE, UP, ORE); // Enable Upper bound unrolling universally, not dependant upon the conditions