Skip to content

Commit b25f082

Browse files
bcheng0127gfxbot
authored andcommitted
Internal
Change-Id: I100b28882f962db70fed3902dc3202972f43c571
1 parent 23f4cb1 commit b25f082

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

visa/G4_Opcode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,5 @@ inline bool isLowPrecisionFloatTy(G4_Type ty)
421421
}
422422

423423
#define SUB_ALIGNMENT_GRFALIGN (Sixteen_Word)
424+
#define SUB_ALIGNMENT_HALFGRFALIGN (Eight_Word)
424425
#endif // _G4_OPCODE_H_

visa/LocalRA.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void LocalRA::evenAlign()
156156
#endif
157157
gra.updateAlignment(G4_GRF, Even);
158158
}
159-
gra.updateSubRegAlignment(G4_GRF, Sixteen_Word);
159+
gra.updateSubRegAlignment(G4_GRF, SUB_ALIGNMENT_GRFALIGN);
160160
// Since we are piggy backing on mask field of G4_Declare,
161161
// we need to make sure we reset it before going further.
162162
resetMasks();
@@ -818,7 +818,7 @@ bool LocalRA::assignUniqueRegisters(bool twoBanksRA, bool twoDirectionsAssign)
818818
}
819819

820820
// Why?
821-
G4_SubReg_Align subAlign = builder.GRFAlign() ? Sixteen_Word : dcl->getSubRegAlign();
821+
G4_SubReg_Align subAlign = builder.GRFAlign() ? SUB_ALIGNMENT_GRFALIGN : dcl->getSubRegAlign();
822822

823823
if (assignFromFront)
824824
{
@@ -1688,9 +1688,9 @@ void LocalRA::countLocalLiveIntervals(std::vector<LocalLiveRange*>& liveInterval
16881688
}
16891689
else
16901690
{
1691-
if (dcl->getNumElems() > 1 && size > 16 && size <= 32)
1691+
if (dcl->getNumElems() > 1 && size > (getGRFSize() / 2u) && size <= (unsigned int)getGRFSize())
16921692
numOneGRF++;
1693-
else if (dcl->getNumElems() > 1 && size <= 16)
1693+
else if (dcl->getNumElems() > 1 && size <= (getGRFSize() / 2u))
16941694
numHalfGRF++;
16951695
else if (dcl->getNumElems() == 1)
16961696
numScalars++;
@@ -1843,6 +1843,7 @@ void PhyRegsLocalRA::setGRFBusy(int which)
18431843
{
18441844
MUST_BE_TRUE(isGRFAvailable(which), "Invalid register");
18451845
regBusyVector[which] = 0xffff;
1846+
18461847
if (twoBanksRA)
18471848
{
18481849
if (which < SECOND_HALF_BANK_START_GRF)
@@ -1884,7 +1885,7 @@ void PhyRegsLocalRA::setWordBusy(int whichgrf, int word)
18841885
}
18851886
}
18861887

1887-
regBusyVector[whichgrf] |= (0x1 << word);
1888+
regBusyVector[whichgrf] |= (WORD_BUSY << word);
18881889
}
18891890

18901891
void PhyRegsLocalRA::setWordBusy(int whichgrf, int word, int howmany)
@@ -1947,7 +1948,7 @@ void PhyRegsLocalRA::setWordNotBusy(int whichgrf, int word, int instID)
19471948
}
19481949
}
19491950
}
1950-
int mask = ~(1 << word);
1951+
uint32_t mask = ~(1 << word);
19511952
regBusyVector[whichgrf] &= mask;
19521953
if (instID)
19531954
{
@@ -2259,15 +2260,15 @@ void PhyRegsLocalRA::markPhyRegs(G4_Declare* topdcl)
22592260
bool PhyRegsLocalRA::findFreeSingleReg(int regIdx, G4_SubReg_Align subalign, int &regnum, int &subregnum, int size)
22602261
{
22612262
bool found = false;
2262-
if (subalign == Sixteen_Word)
2263+
if (subalign == SUB_ALIGNMENT_GRFALIGN)
22632264
{
22642265
if (isWordBusy(regIdx, 0, size) == false)
22652266
{
22662267
subregnum = 0;
22672268
found = true;
22682269
}
22692270
}
2270-
else if (subalign == Eight_Word)
2271+
else if (subalign == SUB_ALIGNMENT_HALFGRFALIGN)
22712272
{
22722273
if (isWordBusy(regIdx, 0, size) == false)
22732274
{
@@ -2280,7 +2281,8 @@ bool PhyRegsLocalRA::findFreeSingleReg(int regIdx, G4_SubReg_Align subalign, int
22802281
found = true;
22812282
}
22822283
}
2283-
else if (subalign == Four_Word)
2284+
else if (subalign == Eight_Word ||
2285+
subalign == Four_Word)
22842286
{
22852287
for (int j = 0; j < (NUM_WORDS_PER_GRF - size + 1) && found == false; j += 4)
22862288
{

visa/LocalRA.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ enum
248248
WORD_BUSY = 1,
249249
};
250250

251-
#define REG_UNAVAILABLE 0xffff0000
252-
253251
namespace vISA
254252
{
255253
class PhyRegsLocalRA
@@ -263,7 +261,7 @@ class PhyRegsLocalRA
263261
// entire grf busy/available
264262
std::vector<uint32_t> regBusyVector;
265263
std::vector<int32_t> regLastUse;
266-
264+
std::vector<bool> grfAvialable;
267265
int lastUseSum1;
268266
int lastUseSum2;
269267
int bank1AvailableRegNum;
@@ -275,18 +273,20 @@ class PhyRegsLocalRA
275273
bool r1Forbidden;
276274

277275
public:
278-
PhyRegsLocalRA(uint32_t nregs) : numRegs(nregs)
279-
{
280-
uint32_t grfFree = 0;
276+
PhyRegsLocalRA(uint32_t nregs) : numRegs(nregs)
277+
{
278+
uint32_t grfFree = 0;
281279

282280
regBusyVector.resize(numRegs);
283281
regLastUse.resize(numRegs);
282+
grfAvialable.resize(numRegs);
284283

285-
for( int i = 0; i < (int) nregs; i++ )
286-
{
287-
regBusyVector[i] = grfFree;
284+
for( int i = 0; i < (int) nregs; i++ )
285+
{
286+
regBusyVector[i] = grfFree;
288287
regLastUse[i] = 0;
289-
}
288+
grfAvialable[i] = true;
289+
}
290290

291291
lastUseSum1 = 0;
292292
lastUseSum2 = 0;
@@ -339,7 +339,7 @@ class PhyRegsLocalRA
339339

340340
// Available/unavailable is different from busy/free
341341
// Unavailable GRFs are not available for allocation
342-
void setGRFUnavailable( int which ) { regBusyVector[which] = REG_UNAVAILABLE; }
342+
void setGRFUnavailable( int which ) { grfAvialable[which] = false; }
343343
bool isGRFAvailable(int which) const
344344
{
345345

@@ -366,7 +366,7 @@ class PhyRegsLocalRA
366366
else
367367
{
368368
MUST_BE_TRUE(which < (int) numRegs, "invalid GRF");
369-
return (!((regBusyVector[which] & REG_UNAVAILABLE) == REG_UNAVAILABLE));
369+
return (grfAvialable[which] == true);
370370
}
371371
}
372372

0 commit comments

Comments
 (0)