[llvm] [SimplifyCFG]divergent undef predecessor removal (PR #204287)

Fujun Han via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 21 18:26:34 PDT 2026


================
@@ -8906,8 +8906,15 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I, bool PtrValu
 /// If BB has an incoming value that will always trigger undefined behavior
 /// (eg. null pointer dereference), remove the branch leading here.
 static bool removeUndefIntroducingPredecessor(BasicBlock *BB,
+                                              const TargetTransformInfo &TTI,
                                               DomTreeUpdater *DTU,
                                               AssumptionCache *AC) {
+  // On SIMT targets, lanes may concurrently execute different CFG paths.
+  // A PHI incoming undef from one divergent arm does not imply that
+  // predecessor is unreachable.
+  if (TTI.hasBranchDivergence(BB->getParent()))
----------------
Peter9606 wrote:

Thanks for the review. I've dropped the TTI guard and instead bail out in
`passingValueIsAlwaysUndefined` when poison flows to a `noundef` argument of
a convergent call. The test now uses a convergent callee for the AMDGPU case
and a non-convergent callee for the scalar fold case.

https://github.com/llvm/llvm-project/pull/204287


More information about the llvm-commits mailing list