Skip to content

Commit e47e4d8

Browse files
authored
[AMDGPU] SIInsertHardClause: add configurable clause length limit (#142343)
Add command line and function attribute configuration of hard clause length limit (within hardware maximum). This allows performance tuning for shaders which benefit from smaller clauses.
1 parent aef4373 commit e47e4d8

File tree

3 files changed

+463
-2
lines changed

3 files changed

+463
-2
lines changed

llvm/lib/Target/AMDGPU/SIInsertHardClauses.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ using namespace llvm;
4242

4343
#define DEBUG_TYPE "si-insert-hard-clauses"
4444

45+
static cl::opt<unsigned>
46+
HardClauseLengthLimit("amdgpu-hard-clause-length-limit",
47+
cl::desc("Maximum number of memory instructions to "
48+
"place in the same hard clause"),
49+
cl::Hidden);
50+
4551
namespace {
4652

4753
enum HardClauseType {
@@ -185,11 +191,18 @@ class SIInsertHardClauses {
185191
}
186192

187193
bool run(MachineFunction &MF) {
188-
189194
ST = &MF.getSubtarget<GCNSubtarget>();
190195
if (!ST->hasHardClauses())
191196
return false;
192197

198+
unsigned MaxClauseLength = MF.getFunction().getFnAttributeAsParsedInteger(
199+
"amdgpu-hard-clause-length-limit", 255);
200+
if (HardClauseLengthLimit.getNumOccurrences())
201+
MaxClauseLength = HardClauseLengthLimit;
202+
MaxClauseLength = std::min(MaxClauseLength, ST->maxHardClauseLength());
203+
if (MaxClauseLength <= 1)
204+
return false;
205+
193206
const SIInstrInfo *SII = ST->getInstrInfo();
194207
const TargetRegisterInfo *TRI = ST->getRegisterInfo();
195208

@@ -212,7 +225,7 @@ class SIInsertHardClauses {
212225
}
213226
}
214227

215-
if (CI.Length == ST->maxHardClauseLength() ||
228+
if (CI.Length == MaxClauseLength ||
216229
(CI.Length && Type != HARDCLAUSE_INTERNAL &&
217230
Type != HARDCLAUSE_IGNORE &&
218231
(Type != CI.Type ||

0 commit comments

Comments
 (0)