Skip to content

Commit 2ea7d9f

Browse files
kychendevigcbot
authored andcommitted
Improve flag RA to reduce spilling.
Improve flag RA to reduce spilling and enforce correct alignment.
1 parent 49bf60d commit 2ea7d9f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

visa/GraphColor.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12332,18 +12332,15 @@ void GlobalRA::fixAlignment()
1233212332
// Rest of RA shouldnt have to read/modify alignment of G4_RegVar
1233312333
copyAlignment();
1233412334

12335-
if (kernel.getSimdSize() == g4::SIMD32)
12335+
for (auto dcl : kernel.Declares)
1233612336
{
12337-
// we have to force all flags to be 32-bit aligned even if they are < 32-bit,
12338-
// due to potential emask usage.
12339-
// ToDo: may be better to simply allocate them as 32-bit?
12340-
for (auto dcl : kernel.Declares)
12341-
{
12342-
if (dcl->getRegFile() & G4_FLAG)
12343-
{
12344-
setSubRegAlign(dcl, G4_SubReg_Align::Even_Word);
12345-
}
12346-
}
12337+
if (dcl->getRegFile() & G4_FLAG)
12338+
{
12339+
if (dcl->getByteSize() > 2 ||
12340+
(kernel.getSimdSize() == g4::SIMD32 &&
12341+
kernel.getInt32KernelAttr(Attributes::ATTR_Target) != VISA_CM))
12342+
setSubRegAlign(dcl, G4_SubReg_Align::Even_Word);
12343+
}
1234712344
}
1234812345

1234912346
if (builder.getPlatform() == GENX_BDW)

visa/VisaToG4/TranslateSendSync.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ int IR_Builder::translateVISANamedBarrierWait(G4_Operand* barrierId)
321321
if (barrierId->isSrcRegRegion()) {
322322
// sync can take only flag src
323323
G4_Declare* flagDecl = createTempFlag(1);
324+
flagDecl->setSubRegAlign(Even_Word);
324325
createMov(g4::SIMD1, createDstRegRegion(flagDecl, 1), barrierId,
325326
InstOpt_WriteEnable, true);
326327
barSrc = createSrcRegRegion(flagDecl, getRegionScalar());

0 commit comments

Comments
 (0)