Skip to content

Commit c654cf0

Browse files
committed
[UniformAnalysis] Changes based on feedback
Based on feedback, modifying early stop involving loops and minor lit test fix.
1 parent e9d7dcc commit c654cf0

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

llvm/include/llvm/ADT/GenericUniformityImpl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ template <typename ContextT> class DivergencePropagator {
630630
auto IsInIrreducibleCycle = [this](const BlockT *B) {
631631
for (const auto *Cycle = CI.getCycle(B); Cycle;
632632
Cycle = Cycle->getParentCycle()) {
633+
// If everything is inside a reducible cycle, then look no further
634+
if (Cycle->isReducible() && Cycle->contains(&DivTermBlock))
635+
return false;
633636
if (!Cycle->isReducible())
634637
return true;
635638
}
@@ -638,12 +641,9 @@ template <typename ContextT> class DivergencePropagator {
638641

639642
// Technically propagation can continue until it reaches the last node.
640643
//
641-
// For efficiency, propagation can just stop at the IPD (immediate
642-
// post-dominator) of successors(DivTemBlock) for any reducible graph.
643-
// If FreshLabels.count()=1, the block in FreshLabels should be the IPD.
644-
//
645-
// For irreducible cycle, propagation continues until it reaches out of
646-
// any irreducible cycles first, then stop when FreshLabels.count()=1.
644+
// For efficiency, propagation can stop if FreshLabels.count()==1. But
645+
// For irreducible cycles, let propagation continue until it reaches
646+
// out of irreducible cycles (see code for details.)
647647
while (true) {
648648
auto BlockIdx = FreshLabels.find_last();
649649
if (BlockIdx == -1)

llvm/test/Analysis/UniformityAnalysis/AMDGPU/phi_div_branch.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
;
21
; RUN: opt -mtriple amdgcn-- -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s
32
;
43
; This is to test an if-then-else case with some unmerged basic blocks
@@ -73,6 +72,4 @@ B8:
7372
}
7473

7574

76-
declare i32 @llvm.amdgcn.workitem.id.x() #0
77-
78-
attributes #0 = {nounwind readnone }
75+
declare i32 @llvm.amdgcn.workitem.id.x()

llvm/test/Analysis/UniformityAnalysis/AMDGPU/phi_div_loop.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
;
21
; RUN: opt -mtriple amdgcn-- -passes='print<uniformity>' -disable-output %s 2>&1 | FileCheck %s
32
;
43
; This is to test a divergent phi involving loops
@@ -77,6 +76,4 @@ B8:
7776
ret void
7877
}
7978

80-
declare i32 @llvm.amdgcn.workitem.id.x() #0
81-
82-
attributes #0 = {nounwind readnone }
79+
declare i32 @llvm.amdgcn.workitem.id.x()

0 commit comments

Comments
 (0)