[llvm] [Uniformity] Avoid marking all PHIs as divergent in join blocks (PR #157808)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 5 23:13:27 PDT 2025


================
@@ -68,6 +69,23 @@ bool SSAContext::isConstantOrUndefValuePhi(const Instruction &Instr) {
   return false;
 }
 
+template <>
+void SSAContext::getPhiInputs(
+    const Instruction &Instr, SmallVectorImpl<const Value *> &Values,
+    SmallVectorImpl<const BasicBlock *> &Blocks) const {
+  assert(isa<PHINode>(Instr));
+  const PHINode *Phi = static_cast<const PHINode *>(&Instr);
+  for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I) {
+    const Value *Incoming = Phi->getIncomingValue(I);
+    const BasicBlock *Block = Phi->getIncomingBlock(I);
+    // FIXME: should this also consider Incoming == &Instr undef?
----------------
ssahasra wrote:

If all the dominating inputs are well-defined, then this self-reference is not undef, right? If at this point we find that indeed `Incoming == &Instr`, then I am not able to decide if treating it as `undef` is always correct. Ultimately, it the uniformity itself has to be `false` unless proven otherwise.

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


More information about the llvm-commits mailing list