Skip to content

Commit 43ba411

Browse files
jgu222sys_zuul
authored andcommitted
If a goto is uniform and it is in divergent BB, this goto
will affect divergence (goto BB to its target are divergent). If it is uniform and not in divergent BB, it does not affect divergence. Change-Id: I83efb23b0569c7b7c76e6d63f979819a95cb9dc0
1 parent 4db6f9a commit 43ba411

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

visa/FlowGraph.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,9 +2994,8 @@ void FlowGraph::markDivergentBBs()
29942994
continue;
29952995
}
29962996
G4_INST* tmpInst = BB1->back();
2997-
if ((tmpInst->opcode() == G4_break || tmpInst->opcode() == G4_goto) &&
2998-
!tmpInst->asCFInst()->isUniform())
2999-
{
2997+
if (tmpInst->opcode() == G4_break || tmpInst->opcode() == G4_goto)
2998+
{ // Assume divergent. todo: going over loop twice to find if it's divergent.
30002999
G4_BB* newJoinBB = joinBB;
30013000
if (tmpInst->opcode() == G4_goto)
30023001
{
@@ -3035,14 +3034,16 @@ void FlowGraph::markDivergentBBs()
30353034

30363035
G4_INST* lastInst = BB->back();
30373036
if (((lastInst->opcode() == G4_goto && !lastInst->asCFInst()->isBackward()) ||
3038-
lastInst->opcode() == G4_break) && !lastInst->asCFInst()->isUniform())
3037+
lastInst->opcode() == G4_break) &&
3038+
(!lastInst->asCFInst()->isUniform() || BB->isDivergent()))
30393039
{
30403040
// forward goto/break : the last Succ BB is our target BB
30413041
// For break, it should be the BB right after while inst.
30423042
G4_BB* joinBB = BB->Succs.back();
30433043
pushJoin(joinBB);
30443044
}
3045-
else if (lastInst->opcode() == G4_if && !lastInst->asCFInst()->isUniform())
3045+
else if (lastInst->opcode() == G4_if &&
3046+
(!lastInst->asCFInst()->isUniform() || BB->isDivergent()))
30463047
{
30473048
G4_Label* labelInst = lastInst->asCFInst()->getUip();
30483049
G4_BB* joinBB = findLabelBB(IT, IE, labelInst->getLabel());

0 commit comments

Comments
 (0)