Skip to content

Commit 24cab01

Browse files
committed
[AMDGPU] SelectionDAG divergence tracking. Reviewer comments addressed.
1 parent 438cebe commit 24cab01

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ SDValue SelectionDAG::getRegister(Register Reg, EVT VT) {
23292329

23302330
auto *N = newSDNode<RegisterSDNode>(Reg, VTs);
23312331
N->SDNodeBits.IsDivergent =
2332-
DivergentTarget ? TLI->isSDNodeSourceOfDivergence(N, FLI, UA) : false;
2332+
DivergentTarget && TLI->isSDNodeSourceOfDivergence(N, FLI, UA);
23332333
CSEMap.InsertNode(N, IP);
23342334
InsertNode(N);
23352335
return SDValue(N, 0);
@@ -10931,8 +10931,7 @@ SDNode *SelectionDAG::UpdateNodeOperands(SDNode *N, SDValue Op) {
1093110931
// Now we update the operands.
1093210932
N->OperandList[0].set(Op);
1093310933

10934-
if (DivergentTarget)
10935-
updateDivergence(N);
10934+
updateDivergence(N);
1093610935
// If this gets put into a CSE map, add it.
1093710936
if (InsertPos) CSEMap.InsertNode(N, InsertPos);
1093810937
return N;
@@ -10961,8 +10960,7 @@ SDNode *SelectionDAG::UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2) {
1096110960
if (N->OperandList[1] != Op2)
1096210961
N->OperandList[1].set(Op2);
1096310962

10964-
if (DivergentTarget)
10965-
updateDivergence(N);
10963+
updateDivergence(N);
1096610964
// If this gets put into a CSE map, add it.
1096710965
if (InsertPos) CSEMap.InsertNode(N, InsertPos);
1096810966
return N;
@@ -11013,8 +11011,7 @@ UpdateNodeOperands(SDNode *N, ArrayRef<SDValue> Ops) {
1101311011
if (N->OperandList[i] != Ops[i])
1101411012
N->OperandList[i].set(Ops[i]);
1101511013

11016-
if (DivergentTarget)
11017-
updateDivergence(N);
11014+
updateDivergence(N);
1101811015
// If this gets put into a CSE map, add it.
1101911016
if (InsertPos) CSEMap.InsertNode(N, InsertPos);
1102011017
return N;
@@ -11801,9 +11798,8 @@ void SelectionDAG::ReplaceAllUsesWith(SDValue FromN, SDValue To) {
1180111798
SDUse &Use = *UI;
1180211799
++UI;
1180311800
Use.set(To);
11804-
if (DivergentTarget)
11805-
if (To->isDivergent() != From->isDivergent())
11806-
updateDivergence(User);
11801+
if (To->isDivergent() != From->isDivergent())
11802+
updateDivergence(User);
1180711803
} while (UI != UE && UI->getUser() == User);
1180811804
// Now that we have modified User, add it back to the CSE maps. If it
1180911805
// already exists there, recursively merge the results together.
@@ -11860,9 +11856,8 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From, SDNode *To) {
1186011856
SDUse &Use = *UI;
1186111857
++UI;
1186211858
Use.setNode(To);
11863-
if (DivergentTarget)
11864-
if (To->isDivergent() != From->isDivergent())
11865-
updateDivergence(User);
11859+
if (To->isDivergent() != From->isDivergent())
11860+
updateDivergence(User);
1186611861
} while (UI != UE && UI->getUser() == User);
1186711862

1186811863
// Now that we have modified User, add it back to the CSE maps. If it
@@ -11914,9 +11909,8 @@ void SelectionDAG::ReplaceAllUsesWith(SDNode *From, const SDValue *To) {
1191411909
To_IsDivergent |= ToOp->isDivergent();
1191511910
} while (UI != UE && UI->getUser() == User);
1191611911

11917-
if (DivergentTarget)
11918-
if (To_IsDivergent != From->isDivergent())
11919-
updateDivergence(User);
11912+
if (To_IsDivergent != From->isDivergent())
11913+
updateDivergence(User);
1192011914

1192111915
// Now that we have modified User, add it back to the CSE maps. If it
1192211916
// already exists there, recursively merge the results together.
@@ -11976,9 +11970,8 @@ void SelectionDAG::ReplaceAllUsesOfValueWith(SDValue From, SDValue To){
1197611970

1197711971
++UI;
1197811972
Use.set(To);
11979-
if (DivergentTarget)
11980-
if (To->isDivergent() != From->isDivergent())
11981-
updateDivergence(User);
11973+
if (To->isDivergent() != From->isDivergent())
11974+
updateDivergence(User);
1198211975
} while (UI != UE && UI->getUser() == User);
1198311976
// We are iterating over all uses of the From node, so if a use
1198411977
// doesn't use the specific value, no changes are made.
@@ -12062,6 +12055,8 @@ bool SelectionDAG::calculateDivergence(SDNode *N) {
1206212055
}
1206312056

1206412057
void SelectionDAG::updateDivergence(SDNode *N) {
12058+
if (!DivergentTarget)
12059+
return;
1206512060
SmallVector<SDNode *, 16> Worklist(1, N);
1206612061
do {
1206712062
N = Worklist.pop_back_val();

0 commit comments

Comments
 (0)