Skip to content

Commit 0700496

Browse files
tbujewskgfxbot
authored andcommitted
Revert of:
A set of small optimizations to reduce compilation time Change-Id: If7d69249e4a158c713d304c5668d4380f3449da9
1 parent 9c5302c commit 0700496

20 files changed

+394
-323
lines changed

visa/BinaryEncoding.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,7 @@ inline BinaryEncoding::Status BinaryEncoding::ProduceBinaryInstructions()
29532953
SetInstCounts((uint32_t)globalHalfInstNum);
29542954

29552955
EncodingHelper::dumpOptReport(globalInstNum, numCompactedInst, numCompacted3SrcInst, kernel);
2956-
for (auto x = offsetVector.begin(), vEnd = offsetVector.end(); x != vEnd; x++)
2956+
for (auto x = offsetVector.begin(); x != offsetVector.end(); x++)
29572957
{
29582958
// calculate offsets again since labels for forward jumps/calls
29592959
// are available now

visa/BinaryEncodingCNL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ void BinaryEncodingCNL::DoAll()
25782578
SetInstCounts((uint32_t)globalHalfInstNum);
25792579

25802580
EncodingHelper::dumpOptReport(globalInstNum, numCompactedInst, numCompacted3SrcInst, kernel);
2581-
for (auto x = offsetVector.begin(), vEnd = offsetVector.end(); x != vEnd; x++)
2581+
for (auto x = offsetVector.begin(); x != offsetVector.end(); x++)
25822582
{
25832583
if (!EncodeConditionalBranches(x->inst, x->offset))
25842584
{

visa/BuildCISAIRImpl.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,12 @@ void saveFCallState(G4_Kernel* kernel, savedFCallStates& savedFCallState)
443443
// the IR can be reused for another kernel rather than
444444
// recompiling.
445445
// kernel points to a stackcall function.
446-
for (auto curBB : kernel->fg.BBs)
446+
for( BB_LIST_ITER bb_it = kernel->fg.BBs.begin();
447+
bb_it != kernel->fg.BBs.end();
448+
bb_it++ )
447449
{
450+
G4_BB* curBB = (*bb_it);
451+
448452
if( curBB->size() > 0 && curBB->isEndWithFCall() )
449453
{
450454
// Save state for this fcall
@@ -538,8 +542,8 @@ void restoreFCallState(G4_Kernel* kernel, savedFCallStates& savedFCallState)
538542

539543
G4_Kernel* Get_Resolved_Compilation_Unit( common_isa_header header, std::list<G4_Kernel*> compilation_units, int idx )
540544
{
541-
for( std::list<G4_Kernel*>::iterator k = compilation_units.begin(), c_end = compilation_units.end();
542-
k != c_end; k++ )
545+
for( std::list<G4_Kernel*>::iterator k = compilation_units.begin();
546+
k != compilation_units.end(); k++ )
543547
{
544548
if( (*k)->fg.builder->getCUnitId() == (header.num_kernels + idx) && (*k)->fg.builder->getIsKernel() == false )
545549
{
@@ -692,7 +696,7 @@ void Stitch_Compiled_Units( common_isa_header header, std::list<G4_Kernel*>& com
692696
}
693697

694698
// Append declarations and color attributes from all callees to kernel
695-
for (auto it = callee_index.begin(), ciEnd = callee_index.end(); it != ciEnd; ++it)
699+
for (auto it = callee_index.begin(); it != callee_index.end(); ++it )
696700
{
697701
G4_Kernel* callee = Get_Resolved_Compilation_Unit( header, compilation_units, (*it) );
698702

@@ -835,17 +839,17 @@ int CISA_IR_Builder::Compile( const char* nameInput)
835839

836840
savedFCallStates savedFCallState;
837841

838-
for(std::list<VISAKernelImpl*>::iterator kernel_it = kernels.begin(), kend = kernels.end();
839-
kernel_it != kend;
842+
for(std::list<VISAKernelImpl*>::iterator kernel_it = kernels.begin();
843+
kernel_it != kernels.end();
840844
kernel_it++)
841845
{
842846
VISAKernelImpl* kernel = (*kernel_it);
843847

844848
saveFCallState(kernel->getKernel(), savedFCallState);
845849
}
846850

847-
for( std::list<VISAKernelImpl*>::iterator func_it = functions.begin(), fend = functions.end();
848-
func_it != fend;
851+
for( std::list<VISAKernelImpl*>::iterator func_it = functions.begin();
852+
func_it != functions.end();
849853
func_it++ )
850854
{
851855
VISAKernelImpl* function = (*func_it);
@@ -1037,8 +1041,8 @@ int CISA_IR_Builder::CreateVISAFileVar(VISA_FileVar *& decl, char *varName, unsi
10371041
if( IS_GEN_BOTH_PATH )
10381042
{
10391043
// Append file var to all kernel/function objects in CISA_IR_Builder
1040-
for( std::list<VISAKernelImpl*>::iterator it = m_kernels.begin(), kend = m_kernels.end();
1041-
it != kend;
1044+
for( std::list<VISAKernelImpl*>::iterator it = m_kernels.begin();
1045+
it != m_kernels.end();
10421046
it++ )
10431047
{
10441048
VISAKernelImpl* kernel = (*it);

visa/CFGStructurizer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ G4_INST* CFGStructurizer::getJmpiInst(G4_BB *bb)
11591159

11601160
void CFGStructurizer::fini()
11611161
{
1162-
for (uint32_t i = 0, size = topANodes.size(); i< size; ++i)
1162+
for (uint32_t i = 0; i< topANodes.size(); ++i)
11631163
{
11641164
deletePST((ANodeHG*)topANodes[i]);
11651165
}
@@ -2169,7 +2169,7 @@ void CFGStructurizer::ANStack_reconstruct(ANodeHG *& node, ANodeBB *ndbb)
21692169

21702170
// Merging from ANStackIx to the top of ANStack is needed to make
21712171
// sure the order of children is correct.
2172-
for (uint32_t i = newNode->ANStackIx + 1, size = ANStack.size(); i < size; ++i)
2172+
for (uint32_t i = newNode->ANStackIx + 1; i < ANStack.size(); ++i)
21732173
{
21742174
ANodeHG *nd = (ANodeHG *)ANStack[i];
21752175
getNewRange(end, exit, nd->getEndBB(), nd->getExitBB());
@@ -3656,7 +3656,7 @@ void CFGStructurizer::run()
36563656
// Now, convert ANodes
36573657
if (topANodes.size() > 0)
36583658
{
3659-
for (uint32_t i = 0, size = topANodes.size(); i < size; ++i)
3659+
for (uint32_t i = 0; i < topANodes.size(); ++i)
36603660
{
36613661
(void)convertPST(topANodes[i], nullptr);
36623662
}

visa/Common_BinaryEncoding.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ void BinaryEncodingBase::FixAlign16Inst(G4_INST* inst)
165165
G4_DstRegRegion* dst = inst->getDst();
166166
dst->setWriteMask(ChannelEnable_XYZW);
167167

168-
// convert sources to align16
169-
for (int k = 0, numSrc = inst->getNumSrc(); k < numSrc; k++)
168+
// convert sources to align16
169+
for (int k = 0; k < inst->getNumSrc(); k++)
170170
{
171171
ASSERT_USER(inst->getSrc(k)->isSrcRegRegion(), "Unexpected src to be converted to ALIGN16!");
172172
G4_SrcRegRegion* src = inst->getSrc(k)->asSrcRegRegion();
@@ -232,7 +232,7 @@ void BinaryEncodingBase::FixAlign16Inst(G4_INST* inst)
232232
// for double/half inst, we have to additionally fix the source as it doesn't support the .r swizzle
233233
if (isDoubleInst)
234234
{
235-
for (int i = 0, numSrc = inst->getNumSrc(); i < numSrc; ++i)
235+
for (int i = 0; i < inst->getNumSrc(); ++i)
236236
{
237237
MUST_BE_TRUE(inst->getSrc(i)->isSrcRegRegion(), "source must have a region");
238238
G4_SrcRegRegion* src = inst->getSrc(i)->asSrcRegRegion();
@@ -254,7 +254,7 @@ void BinaryEncodingBase::FixAlign16Inst(G4_INST* inst)
254254
void BinaryEncodingBase::FixMathInst(G4_INST* inst)
255255
{
256256
MUST_BE_TRUE(inst->isMath(), "Expect math instruction");
257-
for (int i = 0, numSrc = inst->getNumSrc(); i < numSrc; ++i)
257+
for (int i = 0; i < inst->getNumSrc(); ++i)
258258
{
259259
G4_Operand* src = inst->getSrc(i);
260260
if (src && src->isSrcRegRegion())

visa/DebugInfo.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ void KernelDebugInfo::computeMissingVISAIds()
547547
}
548548
}
549549

550-
for (unsigned int i = 0, size = seenVISAIds.size(); i < size; i++)
550+
for (unsigned int i = 0; i < seenVISAIds.size(); i++)
551551
{
552552
if (!seenVISAIds[i])
553553
{
@@ -627,7 +627,7 @@ void KernelDebugInfo::generateByteOffsetMapping(std::list<G4_BB*>& stackCallEntr
627627
unsigned int maxVISAIndex = 0;
628628
uint64_t maxGenIsaOffset = 0;
629629
// Now traverse CFG, create pair of CISA byte offset, gen binary offset and push to vector
630-
for (BB_LIST_ITER bb_it = kernel->fg.BBs.begin(), bbEnd = kernel->fg.BBs.end(); bb_it != bbEnd; bb_it++)
630+
for (BB_LIST_ITER bb_it = kernel->fg.BBs.begin(); bb_it != kernel->fg.BBs.end(); bb_it++)
631631
{
632632
G4_BB* bb = (*bb_it);
633633

@@ -658,8 +658,8 @@ void KernelDebugInfo::generateByteOffsetMapping(std::list<G4_BB*>& stackCallEntr
658658
break;
659659
}
660660

661-
for (INST_LIST_ITER inst_it = bb->begin(), bbEnd = bb->end();
662-
inst_it != bbEnd;
661+
for(INST_LIST_ITER inst_it = bb->begin();
662+
inst_it != bb->end();
663663
inst_it++)
664664
{
665665
G4_INST* inst = (*inst_it);
@@ -954,7 +954,7 @@ unsigned int populateMapDclName(VISAKernelImpl* kernel, std::map<G4_Declare*, st
954954
uint32_t KernelDebugInfo::getVarIndex(G4_Declare* dcl)
955955
{
956956
uint32_t retval = 0xffffffff;
957-
for (uint32_t i = 0, size = varsMap.size(); i < size; i++)
957+
for (uint32_t i = 0; i < varsMap.size(); i++)
958958
{
959959
if (dcl == varsMap[i]->dcl)
960960
{

0 commit comments

Comments
 (0)