Skip to content

Commit 901057c

Browse files
jfuentesigcbot
authored andcommitted
Fix largest input register calculation
1 parent 92d4567 commit 901057c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

visa/G4_Kernel.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -984,16 +984,22 @@ std::string G4_Kernel::getDebugSrcLine(const std::string &fileName,
984984
return lines[srcLine - 1];
985985
}
986986

987+
// Among all the input registers, get the largest one.
988+
// This accounts for input arguments as well as pseudo
989+
// input declarations.
987990
unsigned G4_Kernel::getLargestInputRegister() {
991+
unsigned maxRegNum = 0;
988992
const unsigned inputCount = fg.builder->getInputCount();
989-
unsigned regNum = 0;
990-
if (inputCount) {
991-
const input_info_t *ii = fg.builder->getInputArg(inputCount - 1);
992-
regNum = (ii->offset + ii->dcl->getByteSize()) /
993-
fg.builder->numEltPerGRF<Type_UB>();
994-
}
995-
996-
return regNum;
993+
// Iterate over all the inputs because they can be defined
994+
// in any order by the programmer.
995+
for (unsigned i = 0; i < inputCount; i++) {
996+
const input_info_t *ii = fg.builder->getInputArg(i);
997+
unsigned reg = (ii->offset + ii->dcl->getByteSize()) /
998+
fg.builder->numEltPerGRF<Type_UB>();
999+
if (reg > maxRegNum)
1000+
maxRegNum = reg;
1001+
}
1002+
return maxRegNum;
9971003
}
9981004

9991005
void G4_Kernel::setKernelParameters(unsigned newGRF) {

0 commit comments

Comments
 (0)