[PATCH] D158014: [LLVM][Uniformity] Remove assert thrown on some irreducible control flow

Alex MacLean via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 09:06:55 PDT 2023


AlexM updated this revision to Diff 550779.
AlexM added a comment.

Address comment; move if below while loop.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158014/new/

https://reviews.llvm.org/D158014

Files:
  llvm/include/llvm/ADT/GenericUniformityImpl.h
  llvm/test/Analysis/UniformityAnalysis/NVPTX/non-header-join.ll


Index: llvm/test/Analysis/UniformityAnalysis/NVPTX/non-header-join.ll
===================================================================
--- /dev/null
+++ llvm/test/Analysis/UniformityAnalysis/NVPTX/non-header-join.ll
@@ -0,0 +1,24 @@
+; RUN: opt %s -passes='print<uniformity>' -disable-output 2>&1 | FileCheck %s
+
+target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
+target triple = "nvptx64-nvidia-cuda"
+
+; CHECK: CYCLES ASSSUMED DIVERGENT:
+; CHECK-NEXT: depth=1: entries(if.end16 for.cond1) for.body4
+
+define void @foo(i1 %b) {
+entry:
+  br i1 %b, label %if.then, label %if.end16
+
+if.then:                                          ; preds = %entry
+  br label %for.cond1
+
+for.cond1:                                        ; preds = %if.end16, %for.body4, %if.then
+  br i1 false, label %for.body4, label %if.end16
+
+for.body4:                                        ; preds = %for.cond1
+  br label %for.cond1
+
+if.end16:                                         ; preds = %for.cond1, %entry
+  br label %for.cond1
+}
Index: llvm/include/llvm/ADT/GenericUniformityImpl.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -946,11 +946,6 @@
   if (Cycle->contains(DivTermBlock))
     return nullptr;
 
-  if (Cycle->isReducible()) {
-    assert(Cycle->getHeader() == JoinBlock);
-    return nullptr;
-  }
-
   const auto *Parent = Cycle->getParentCycle();
   while (Parent && !Parent->contains(DivTermBlock)) {
     // If the join is inside a child, then the parent must be
@@ -961,6 +956,11 @@
     Parent = Cycle->getParentCycle();
   }
 
+  if (Cycle->isReducible()) {
+    assert(Cycle->getHeader() == JoinBlock);
+    return nullptr;
+  }
+
   LLVM_DEBUG(dbgs() << "cycle made divergent by external branch\n");
   return Cycle;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158014.550779.patch
Type: text/x-patch
Size: 1875 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/d1da1d76/attachment.bin>


More information about the llvm-commits mailing list