Skip to content

Commit 77e6f43

Browse files
authored
[SPIRV] convergence anchor intrinsic does not have a parent token (#122230)
1 parent 681c4a2 commit 77e6f43

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,13 +1873,13 @@ class ConvergenceControlInst : public IntrinsicInst {
18731873
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
18741874
}
18751875

1876-
bool isAnchor() {
1876+
bool isAnchor() const {
18771877
return getIntrinsicID() == Intrinsic::experimental_convergence_anchor;
18781878
}
1879-
bool isEntry() {
1879+
bool isEntry() const {
18801880
return getIntrinsicID() == Intrinsic::experimental_convergence_entry;
18811881
}
1882-
bool isLoop() {
1882+
bool isLoop() const {
18831883
return getIntrinsicID() == Intrinsic::experimental_convergence_loop;
18841884
}
18851885
};

llvm/lib/Target/SPIRV/Analysis/SPIRVConvergenceRegionAnalysis.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,12 @@ getConvergenceTokenInternal(BasicBlockType *BB) {
5656
"Output type must be an intrinsic instruction.");
5757

5858
for (auto &I : *BB) {
59-
if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
60-
switch (II->getIntrinsicID()) {
61-
case Intrinsic::experimental_convergence_entry:
62-
case Intrinsic::experimental_convergence_loop:
63-
return II;
64-
case Intrinsic::experimental_convergence_anchor: {
65-
auto Bundle = II->getOperandBundle(LLVMContext::OB_convergencectrl);
66-
assert(Bundle->Inputs.size() == 1 &&
67-
Bundle->Inputs[0]->getType()->isTokenTy());
68-
auto TII = dyn_cast<IntrinsicInst>(Bundle->Inputs[0].get());
69-
assert(TII != nullptr);
70-
return TII;
71-
}
72-
}
59+
if (auto *CI = dyn_cast<ConvergenceControlInst>(&I)) {
60+
// Make sure that the anchor or entry intrinsics did not reach here with a
61+
// parent token. This should have failed the verifier.
62+
assert(CI->isLoop() ||
63+
!CI->getOperandBundle(LLVMContext::OB_convergencectrl));
64+
return CI;
7365
}
7466

7567
if (auto *CI = dyn_cast<CallInst>(&I)) {

0 commit comments

Comments
 (0)