[llvm] [VPlan] Add vputils::reconstructSSA (PR #212209)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 02:45:38 PDT 2026


================
@@ -1156,3 +1156,43 @@ void vputils::detail::pullOutPermutationsImpl(
     }
   }
 }
+
+/// Implements the algorithm described in "Simple and Efficient Construction of
+/// Static Single Assignment Form" by Braun et al.
+static VPValue *reconstructSSAImpl(VPBasicBlock *VPBB,
+                                   DenseMap<VPBasicBlock *, VPValue *> &Defs) {
+  if (VPValue *Def = Defs.lookup(VPBB))
+    return Def;
+  // If the entry block is reached and there's still no def, then Defs is
+  // missing a definition that covers this path.
+  assert(VPBB->getNumPredecessors() && "Not all paths have def");
+
+  if (VPBlockBase *Pred = VPBB->getSinglePredecessor())
+    return reconstructSSAImpl(cast<VPBasicBlock>(Pred), Defs);
+
+  // Multiple predecessors, create a join.
+  Type *Ty = Defs.begin()->second->getScalarType();
----------------
lukel97 wrote:

It doesn't change no, but fetching the type is cheap now that we don't have VPTypeAnalysis. I'm not sure there's any benefit to passing it around as an argument. 

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


More information about the llvm-commits mailing list