File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
test/Transforms/IRNormalizer Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -468,8 +468,13 @@ void IRNormalizer::reorderInstructions(Function &F) const {
468468 // Reorder based on the topological sort.
469469 while (!TopologicalSort.empty ()) {
470470 auto *Instruction = TopologicalSort.top ();
471- auto *FirstNonPHIOrDbgOrAlloca = &*BB.getFirstNonPHIOrDbgOrAlloca ();
472- Instruction->moveBefore (FirstNonPHIOrDbgOrAlloca);
471+ auto FirstNonPHIOrDbgOrAlloca = BB.getFirstNonPHIOrDbgOrAlloca ();
472+ if (auto *Call = dyn_cast<CallInst>(&*FirstNonPHIOrDbgOrAlloca)) {
473+ if (Call->getIntrinsicID () == Intrinsic::experimental_convergence_entry ||
474+ Call->getIntrinsicID () == Intrinsic::experimental_convergence_loop)
475+ FirstNonPHIOrDbgOrAlloca++;
476+ }
477+ Instruction->moveBefore (&*FirstNonPHIOrDbgOrAlloca);
473478 TopologicalSort.pop ();
474479 }
475480 }
@@ -508,6 +513,10 @@ void IRNormalizer::reorderDefinition(
508513 return ;
509514 if (Call->getIntrinsicID () == Intrinsic::experimental_deoptimize)
510515 return ;
516+ if (Call->getIntrinsicID () == Intrinsic::experimental_convergence_entry)
517+ return ;
518+ if (Call->getIntrinsicID () == Intrinsic::experimental_convergence_loop)
519+ return ;
511520 }
512521 if (auto *BitCast = dyn_cast<BitCastInst>(Definition)) {
513522 if (auto *Call = dyn_cast<CallInst>(BitCast->getOperand (0 ))) {
Original file line number Diff line number Diff line change 1+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+ ; RUN: opt -S -passes=normalize < %s | FileCheck %s
3+
4+ ; Function Attrs: convergent nounwind readnone
5+ define i32 @nested (i32 %src ) #0 {
6+ ; CHECK-LABEL: define i32 @nested(
7+ ; CHECK-SAME: i32 [[A0:%.*]]) #[[ATTR0:[0-9]+]] {
8+ ; CHECK-NEXT: [[BB15160:.*:]]
9+ ; CHECK-NEXT: [[T1:%.*]] = call token @llvm.experimental.convergence.entry()
10+ ; CHECK-NEXT: %"vl15001llvm.experimental.convergence.anchor()" = call token @llvm.experimental.convergence.anchor()
11+ ; CHECK-NEXT: %"op68297llvm.amdgcn.readfirstlane.i32([[A0]], vl15001llvm.experimental.convergence.anchor())" = call i32 @llvm.amdgcn.readfirstlane.i32(i32 [[A0]]) [ "convergencectrl"(token %"vl15001llvm.experimental.convergence.anchor()") ]
12+ ; CHECK-NEXT: ret i32 undef
13+ ;
14+ %t1 = call token @llvm.experimental.convergence.entry ()
15+ %t2 = call token @llvm.experimental.convergence.anchor ()
16+ %r2 = call i32 @llvm.amdgcn.readfirstlane (i32 %src ) [ "convergencectrl" (token %t2 ) ]
17+ ret i32 undef
18+ }
19+
20+ ; Function Attrs: convergent nounwind readnone
21+ declare i32 @llvm.amdgcn.readfirstlane (i32 ) #0
22+
23+ declare token @llvm.experimental.convergence.entry ()
24+
25+ declare token @llvm.experimental.convergence.anchor ()
26+
27+ attributes #0 = { convergent nounwind readnone }
You can’t perform that action at this time.
0 commit comments