[llvm] [AMDGPU] Rewrite undef PHIs with a unique constant value (PR #214319)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 08:46:11 PDT 2026


================
@@ -140,23 +140,25 @@ bool rewritePHIs(Function &F, UniformityInfo &UA, DominatorTree *DT) {
       }
       // We only need to replace the undef for the PHI which is merging
       // defined/undefined values from divergent threads.
-      // TODO: We should still be able to replace undef value if the unique
-      // value is a Constant.
-      if (!UniqueDefinedIncoming || Undefs.empty() ||
-          UA.isUniformTerminator(DominateBB->getTerminator()))
+      if (!UniqueDefinedIncoming || Undefs.empty())
         continue;
 
       // We only replace the undef when DominateBB truly dominates all the
----------------
robertvirany wrote:

Thanks. The first commit was intended as an intentionally failing regression test. After the second commit the test passes with the desired output. 

I also updated the comment to describe the constant case.

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


More information about the llvm-commits mailing list