Skip to content

Commit c130079

Browse files
weiyu-chensys_zuul
authored and
sys_zuul
committed
Handle 16-byte alignment correct for trivial and local RA.
Change-Id: Iffce10c718fe79d041aa0f9e2ae023438ac5e6de
1 parent d5d2bc3 commit c130079

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

visa/G4Verifier.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,18 @@ void G4Verifier::verifyOpnd(G4_Operand* opnd, G4_INST* inst)
794794
}
795795
}
796796
}
797+
798+
// if src0 is V/UV/VF imm, dst must be 16 byte aligned.
799+
if (inst->opcode() == G4_mov && IS_VTYPE(inst->getSrc(0)->getType()))
800+
{
801+
auto dst = inst->getDst();
802+
// should we assert if dst is not phyReg assigned?
803+
bool dstIsAssigned = dst->getBase()->isRegVar() && dst->getBase()->asRegVar()->isPhyRegAssigned();
804+
if (dstIsAssigned && dst->getLinearizedStart() % 16 != 0)
805+
{
806+
assert(false && "destination of move instruction with V/VF imm is not 16-byte aligned");
807+
}
808+
}
797809
}
798810
}
799811
}

visa/LocalRA.cpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,43 +2311,32 @@ bool PhyRegsLocalRA::findFreeSingleReg(int regIdx, G4_SubReg_Align subalign, int
23112311
found = true;
23122312
}
23132313
}
2314-
else if (subalign == Eight_Word || subalign == Four_Word)
2314+
else
23152315
{
2316-
for (int j = 0; j < (NUM_WORDS_PER_GRF - size + 1) && found == false; j += 4)
2316+
// ToDo: check if dynamic step size has compile time impact
2317+
int step = 1;
2318+
int upBound = NUM_WORDS_PER_GRF - size + 1;
2319+
switch (subalign)
23172320
{
2318-
if (isWordBusy(regIdx, j, size) == false)
2319-
{
2320-
subregnum = j;
2321-
found = true;
2322-
}
2321+
case Eight_Word: step = 8; break;
2322+
case Four_Word: step = 4; break;
2323+
case Even_Word: step = 2; break;
2324+
case Any:
2325+
upBound = NUM_WORDS_PER_GRF - size; //FIXME, why not the last word
2326+
step = 1; break;
2327+
default:
2328+
assert("unexpected alignment");
23232329
}
2324-
}
2325-
else if (subalign == Even_Word)
2326-
{
2327-
for (int j = 0; j < (NUM_WORDS_PER_GRF - size + 1) && found == false; j += 2)
2330+
for (int j = 0; j < upBound; j += step)
23282331
{
2329-
if (isWordBusy(regIdx, j, size) == false)
2330-
{
2331-
subregnum = j;
2332-
found = true;
2333-
}
2334-
}
2335-
}
2336-
else if (subalign == Any)
2337-
{
2338-
for (int j = 0; j < (NUM_WORDS_PER_GRF - size) && found == false; j++)
2339-
{
2340-
if (isWordBusy(regIdx, j, size) == false)
2332+
if (!isWordBusy(regIdx, j, size))
23412333
{
23422334
subregnum = j;
23432335
found = true;
2336+
break;
23442337
}
23452338
}
23462339
}
2347-
else
2348-
{
2349-
ASSERT_USER(false, "Dont know how to allocate this sub-alignment");
2350-
}
23512340

23522341
if (found)
23532342
{

0 commit comments

Comments
 (0)