@@ -76,7 +76,7 @@ HardClauseType getHardClauseType(const MachineInstr &MI) {
76
76
77
77
// Don't form VALU clauses. It's not clear what benefit they give, if any.
78
78
79
- // In practice s_nop is the only internal instructions we're likely to see.
79
+ // In practice s_nop is the only internal instruction we're likely to see.
80
80
// It's safe to treat the rest as illegal.
81
81
if (MI.getOpcode () == AMDGPU::S_NOP)
82
82
return HARDCLAUSE_INTERNAL;
@@ -103,23 +103,25 @@ class SIInsertHardClauses : public MachineFunctionPass {
103
103
// The last non-internal instruction in the clause.
104
104
MachineInstr *Last = nullptr ;
105
105
// The length of the clause including any internal instructions in the
106
- // middle.
106
+ // middle or after the end of the clause .
107
107
unsigned Length = 0 ;
108
108
// The base operands of *Last.
109
109
SmallVector<const MachineOperand *, 4 > BaseOps;
110
110
};
111
111
112
112
bool emitClause (const ClauseInfo &CI, const SIInstrInfo *SII) {
113
- assert (CI.Length ==
114
- std::distance (CI.First ->getIterator (), CI.Last ->getIterator ()) + 1 );
115
- if (CI.Length < 2 )
113
+ // Get the size of the clause excluding any internal instructions at the
114
+ // end.
115
+ unsigned Size =
116
+ std::distance (CI.First ->getIterator (), CI.Last ->getIterator ()) + 1 ;
117
+ if (Size < 2 )
116
118
return false ;
117
- assert (CI. Length <= 64 && " Hard clause is too long!" );
119
+ assert (Size <= 64 && " Hard clause is too long!" );
118
120
119
121
auto &MBB = *CI.First ->getParent ();
120
122
auto ClauseMI =
121
123
BuildMI (MBB, *CI.First , DebugLoc (), SII->get (AMDGPU::S_CLAUSE))
122
- .addImm (CI. Length - 1 );
124
+ .addImm (Size - 1 );
123
125
finalizeBundle (MBB, ClauseMI->getIterator (),
124
126
std::next (CI.Last ->getIterator ()));
125
127
return true ;
0 commit comments