@@ -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::init(255 ), cl::Hidden);
50+
4551namespace {
4652
4753enum 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" , HardClauseLengthLimit);
200+ if (HardClauseLengthLimit.getNumOccurrences ())
201+ MaxClauseLength = HardClauseLengthLimit;
202+ MaxClauseLength = std::min (MaxClauseLength, ST->maxHardClauseLength ());
203+ if (!MaxClauseLength)
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