Skip to content

Commit f654be0

Browse files
jgu222sys_zuul
authored andcommitted
Using isDivergent to replace isInSimdFlow.
Change-Id: I063bcfb7df2fd3560410e3356c65237f8d158e5e
1 parent decc836 commit f654be0

File tree

3 files changed

+7
-79
lines changed

3 files changed

+7
-79
lines changed

visa/FlowGraph.cpp

Lines changed: 4 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,6 @@ G4_BB* FlowGraph::createNewBB(bool insertInFG)
240240
if (insertInFG)
241241
numBBId++;
242242

243-
if (builder->getOptions()->getTarget() == VISA_3D)
244-
{
245-
// all 3D bbs are considered to be in SIMD CF since the dispatch mask may
246-
// have some channels off.
247-
bb->setInSimdFlow(true);
248-
}
249-
250243
BBAllocList.push_back(bb);
251244
return bb;
252245
}
@@ -905,7 +898,7 @@ void FlowGraph::constructFlowGraph(INST_LIST& instlist)
905898

906899
if (hasSIMDCF && pKernel->getIntKernelAttribute(Attributes::ATTR_Target) == VISA_CM)
907900
{
908-
markSimdBlocks(labelMap, funcInfoHashTable);
901+
processSCF(labelMap, funcInfoHashTable);
909902
addSIMDEdges();
910903
}
911904

@@ -2595,19 +2588,17 @@ G4_BB* FlowGraph::findLabelBB(
25952588

25962589

25972590
/*
2598-
* Mark blocks that are nested in SIMD control flow.
2599-
* Only structured CF is handled here, SIMD BBs due to goto/join
2600-
* are marked in processGoto()
2591+
* This function sets the JIP for Structured CF (SCF) instructions, Unstructured
2592+
* Control Flow (UCF) instructions (goto) are handled in processGoto().
26012593
*
2602-
* This function also sets the JIP of the endif to its enclosing endif/while, if it exists
26032594
* Note: we currently do not consider goto/join when adding the JIP for endif,
26042595
* since structure analysis should not allow goto into/out of if-endif. This means
26052596
* we only need to set the the JIP of the endif to its immediately enclosing endif/while
26062597
*
26072598
* The simd control flow blocks must be well-structured
26082599
*
26092600
*/
2610-
void FlowGraph::markSimdBlocks(std::map<std::string, G4_BB*>& labelMap, FuncInfoHashTable &FuncInfoMap)
2601+
void FlowGraph::processSCF(std::map<std::string, G4_BB*>& labelMap, FuncInfoHashTable &FuncInfoMap)
26112602
{
26122603
std::stack<StructuredCF*> ifAndLoops;
26132604
std::vector<StructuredCF*> structuredSimdCF;
@@ -2659,11 +2650,6 @@ void FlowGraph::markSimdBlocks(std::map<std::string, G4_BB*>& labelMap, FuncInfo
26592650
}
26602651
}
26612652

2662-
if (ifAndLoops.size() > 0)
2663-
{
2664-
bb->setInSimdFlow(true);
2665-
}
2666-
26672653
if (bb->size() > 0)
26682654
{
26692655
G4_INST* lastInst = bb->back();
@@ -2698,45 +2684,6 @@ void FlowGraph::markSimdBlocks(std::map<std::string, G4_BB*>& labelMap, FuncInfo
26982684
setJIPForEndif(cf->mEndInst, cf->enclosingCF->mEndInst, cf->enclosingCF->mEndBB);
26992685
}
27002686
}
2701-
2702-
// Visit the call graph, and mark simd blocks in subroutines.
2703-
std::set<FuncInfo*> Visited;
2704-
std::queue<FuncInfo*> Funcs;
2705-
2706-
// Starting with kernel.
2707-
Funcs.push(kernelInfo);
2708-
2709-
// Now process all subroutines called in a simd-cf block.
2710-
while (!Funcs.empty())
2711-
{
2712-
FuncInfo* CallerInfo = Funcs.front();
2713-
Funcs.pop();
2714-
2715-
// Skip if this is already visited.
2716-
if (!Visited.insert(CallerInfo).second)
2717-
continue;
2718-
2719-
for (auto BB : CallerInfo->getBBList())
2720-
{
2721-
if (BB->isInSimdFlow() && BB->isEndWithCall())
2722-
{
2723-
G4_INST *CI = BB->back();
2724-
if (CI->getSrc(0)->isLabel())
2725-
{
2726-
G4_Label* Callee = CI->getSrc(0)->asLabel();
2727-
G4_BB* CalleeEntryBB = labelMap[Callee->getLabel()];
2728-
FuncInfo* CalleeInfo = CalleeEntryBB->getFuncInfo();
2729-
Funcs.push(CalleeInfo);
2730-
2731-
// Mark all blocks in this subroutine.
2732-
for (auto BB1 : CalleeInfo->getBBList())
2733-
{
2734-
BB1->setInSimdFlow(true);
2735-
}
2736-
}
2737-
}
2738-
}
2739-
}
27402687
}
27412688

27422689
// markDivergentBBs()
@@ -2770,7 +2717,6 @@ void FlowGraph::markDivergentBBs()
27702717
for (auto IT = BBs.begin(), IE = BBs.end(); IT != IE; ++IT)
27712718
{
27722719
G4_BB* BB = *IT;
2773-
BB->setInSimdFlow(true);
27742720
BB->setDivergent(true);
27752721
}
27762722
return;
@@ -3012,9 +2958,6 @@ void FlowGraph::markDivergentBBs()
30122958
G4_BB* BB = *IT;
30132959

30142960
BB->setDivergent(true);
3015-
// set InSIMDFlow as well, will merge two gradually
3016-
BB->setInSimdFlow(true);
3017-
30182961
if (BB->size() == 0)
30192962
{
30202963
// sanity check
@@ -3147,8 +3090,6 @@ void FlowGraph::markDivergentBBs()
31473090
// normal scan of BB
31483091
if (isPriorToLastJoin(BB)) {
31493092
BB->setDivergent(true);
3150-
// set InSIMDFlow as well, will merge these two fields gradually
3151-
BB->setInSimdFlow(true);
31523093
}
31533094
// Temporary for debugging, toBeDelete!
31543095
// if (pKernel->getIntKernelAttribute(Attributes::ATTR_Target) == VISA_CM)
@@ -3452,13 +3393,6 @@ void FlowGraph::processGoto(bool HasSIMDCF)
34523393
}
34533394
}
34543395

3455-
// at this point if there are active join blocks, we are in SIMD control flow
3456-
// FIXME: This is over pessimistic for kernels with actual simd cf.
3457-
if (HasSIMDCF && !activeJoinBlocks.empty())
3458-
{
3459-
bb->setInSimdFlow(true);
3460-
}
3461-
34623396
G4_INST* lastInst = bb->back();
34633397
if (lastInst->opcode() == G4_goto && !lastInst->asCFInst()->isBackward())
34643398
{

visa/FlowGraph.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,9 @@ class G4_BB
282282
// indicates the scoping info in call graph
283283
unsigned scopeID;
284284

285-
// if the block is under simd flow control
286-
bool inSimdFlow;
287-
288285
// If a BB is divergent, this field is set to true. By divergent, it means
289286
// that among all active lanes on entry to shader/kernel, not all lanes may
290287
// be active in this BB.
291-
// Note : this field will be used to replace inSimdFlow.
292288
bool divergent;
293289

294290
// the physical pred/succ for this block (i.e., the pred/succ for this block in the BB list)
@@ -376,7 +372,7 @@ class G4_BB
376372
traversal(0), beforeCall(NULL),
377373
afterCall(NULL), calleeInfo(NULL), BBType(G4_BB_NONE_TYPE),
378374
inNaturalLoop(false), hasSendInBB(false), loopNestLevel(0), scopeID(0),
379-
inSimdFlow(false), divergent(false), physicalPred(NULL), physicalSucc(NULL),
375+
divergent(false), physicalPred(NULL), physicalSucc(NULL),
380376
parent(fg), instList(alloc)
381377
{
382378
}
@@ -422,8 +418,6 @@ class G4_BB
422418
void setNestLevel() {loopNestLevel ++;}
423419
unsigned char getNestLevel() {return loopNestLevel;}
424420
void resetNestLevel() { loopNestLevel = 0; }
425-
void setInSimdFlow(bool val) {inSimdFlow = val;}
426-
bool isInSimdFlow() const {return inSimdFlow;}
427421
void setDivergent(bool val) { divergent = val; }
428422
bool isDivergent() const { return divergent; }
429423
bool isAllLaneActive() const;
@@ -923,6 +917,7 @@ class FlowGraph
923917
void decoupleExitBlock(G4_BB*);
924918
void normalizeSubRoutineBB( FuncInfoHashTable& funcInfoTable );
925919
void processGoto(bool HasSIMDCF);
920+
void processSCF(std::map<std::string, G4_BB*>& labelMap, FuncInfoHashTable& FuncInfoMap);
926921
void insertJoinToBB( G4_BB* bb, uint8_t execSize, G4_Label* jip );
927922

928923
// functions for structure analysis
@@ -1071,7 +1066,6 @@ class FlowGraph
10711066

10721067
void addFrameSetupDeclares(IR_Builder& builder, PhyRegPool& regPool);
10731068
void addSaveRestorePseudoDeclares(IR_Builder& builder);
1074-
void markSimdBlocks(std::map<std::string, G4_BB*>& labelMap, FuncInfoHashTable &FuncInfoMap);
10751069
void markDivergentBBs();
10761070

10771071
// Used for CISA 3.0

visa/LVN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ bool LVN::valuesMatch(Value& val1, Value& val2, bool checkNegImm)
14331433
return false;
14341434
}
14351435

1436-
if (match && bb->isInSimdFlow())
1436+
if (match && !bb->isAllLaneActive())
14371437
{
14381438
G4_INST* val1Inst = val1.inst;
14391439
G4_INST* val2Inst = val2.inst;

0 commit comments

Comments
 (0)