Skip to content

Commit be8eb11

Browse files
jgu222sys_zuul
authored and
sys_zuul
committed
If the message needs to create a new cvar or uses block/read-write,
no need to set grf aligned as the new var will be aligned anyway. Change-Id: Iaec29883e37c5d0dbb56f63d01082652bcdf5c80
1 parent a9e8a7d commit be8eb11

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,20 +1786,30 @@ static e_alignment GetPreferredAlignmentOnUse(llvm::Value* V, WIAnalysis* WIA,
17861786
{
17871787
auto getAlign = [](Value* aV, WIAnalysis* aWIA, CodeGenContext* pCtx) -> e_alignment
17881788
{
1789-
// If uniform variables are once used by uniform loads, stores, or atomic
1790-
// ops, they need being GRF aligned.
1789+
// Once uniform variables are used by uniform loads, stores, or atomic
1790+
// ops, they need being GRF aligned, except that for block read/write
1791+
// or vector load/store with > 1 elements. The block read/write's address
1792+
// is just a field in its header payload so no need to grf-aligned; Vector
1793+
// load/store with > 1 elements needs to create a new cvar anyway to hold
1794+
// scatter load/store address [see detail in vector load/store].
17911795
for (auto UI = aV->user_begin(), UE = aV->user_end(); UI != UE; ++UI) {
1792-
if (LoadInst* ST = dyn_cast<LoadInst>(*UI)) {
1793-
Value* Ptr = ST->getPointerOperand();
1794-
if (aWIA->whichDepend(Ptr) == WIAnalysis::UNIFORM) {
1796+
if (LoadInst* LI = dyn_cast<LoadInst>(*UI)) {
1797+
Value* Ptr = LI->getPointerOperand();
1798+
// If Ptr is uniform and loads a scalar, need [2]grf-alignment.
1799+
VectorType* vTy = dyn_cast<VectorType>(LI->getType());
1800+
if (aWIA->whichDepend(Ptr) == WIAnalysis::UNIFORM &&
1801+
!(vTy && vTy->getNumElements() > 1)) {
17951802
if (IGC::isA64Ptr(cast<PointerType>(Ptr->getType()), pCtx))
17961803
return EALIGN_2GRF;
17971804
return EALIGN_GRF;
17981805
}
17991806
}
18001807
if (StoreInst* ST = dyn_cast<StoreInst>(*UI)) {
18011808
Value* Ptr = ST->getPointerOperand();
1802-
if (aWIA->whichDepend(Ptr) == WIAnalysis::UNIFORM) {
1809+
VectorType* vTy = dyn_cast<VectorType>(ST->getValueOperand()->getType());
1810+
// If Ptr is uniform and stores a scalar, need [2]grf-alignment.
1811+
if (aWIA->whichDepend(Ptr) == WIAnalysis::UNIFORM &&
1812+
!(vTy && vTy->getNumElements() > 1)) {
18031813
if (IGC::isA64Ptr(cast<PointerType>(Ptr->getType()), pCtx))
18041814
return EALIGN_2GRF;
18051815
return EALIGN_GRF;

0 commit comments

Comments
 (0)