Skip to content

Commit e3f8b5f

Browse files
Gang Y Chenigcbot
authored andcommitted
When assume-uniform, always promote the array to register
1 parent ee48299 commit e3f8b5f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

IGC/Compiler/CISACodeGen/AnnotateUniformAllocas.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace IGC
8484
bool isUniformAlloca = WI->isUniform(&I);
8585
if (isUniformAlloca)
8686
{
87+
// add the meta-date to the alloca for promotion
8788
IRBuilder<> builder(&I);
8889
MDNode* node = MDNode::get(I.getContext(), ConstantAsMetadata::get(builder.getInt1(true)));
8990
I.setMetadata("uniform", node);
@@ -98,7 +99,25 @@ namespace IGC
9899
if (pIntr->getIntrinsicID() == GenISAIntrinsic::GenISA_assume_uniform)
99100
{
100101
AssumeToErase.push_back(pIntr);
102+
// add the meta-date to the alloca for promotion
103+
auto OpV = pIntr->getOperand(0);
104+
while (OpV)
105+
{
106+
if (auto CI = dyn_cast<CastInst>(OpV))
107+
{
108+
OpV = CI->getOperand(0);
109+
continue;
110+
}
111+
if (auto ALI = dyn_cast<AllocaInst>(OpV))
112+
{
113+
IRBuilder<> builder(ALI);
114+
MDNode* node = MDNode::get(ALI->getContext(),
115+
ConstantAsMetadata::get(builder.getInt1(true)));
116+
ALI->setMetadata("UseAssumeUniform", node);
117+
}
118+
break;
119+
}
101120
}
102121
}
103122
}
104-
}
123+
}

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ bool LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst* pAlloca)
274274
return false;
275275

276276
bool isUniformAlloca = pAlloca->getMetadata("uniform") != nullptr;
277+
bool useAssumeUniform = pAlloca->getMetadata("UseAssumeUniform") != nullptr;
277278
unsigned int allocaSize = extractConstAllocaSize(pAlloca);
278279
unsigned int allowedAllocaSizeInBytes = MAX_ALLOCA_PROMOTE_GRF_NUM * 4;
279280

@@ -315,7 +316,7 @@ bool LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst* pAlloca)
315316
allocaSize = iSTD::Round(allocaSize, SIMD_PRESSURE_MULTIPLIER) / SIMD_PRESSURE_MULTIPLIER;
316317
}
317318

318-
if (allocaSize <= IGC_GET_FLAG_VALUE(ByPassAllocaSizeHeuristic))
319+
if (useAssumeUniform || allocaSize <= IGC_GET_FLAG_VALUE(ByPassAllocaSizeHeuristic))
319320
{
320321
return true;
321322
}

0 commit comments

Comments
 (0)