[llvm] 53e7f9a - [VPlan] Generalize header-phi detection in VPPhi::execute. (NFC) (#189352)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 04:21:28 PDT 2026


Author: Florian Hahn
Date: 2026-03-30T12:21:22+01:00
New Revision: 53e7f9ada45a71e1cecd14c5ce8dc441a9257501

URL: https://github.com/llvm/llvm-project/commit/53e7f9ada45a71e1cecd14c5ce8dc441a9257501
DIFF: https://github.com/llvm/llvm-project/commit/53e7f9ada45a71e1cecd14c5ce8dc441a9257501.diff

LOG: [VPlan] Generalize header-phi detection in VPPhi::execute. (NFC) (#189352)

Generalize the header-phi detection in VPPhi::execute to use VPDT.

This is currently NFC, but is needed to use VPPhi also for dissolving
replicate regions (https://github.com/llvm/llvm-project/pull/186252).

Split off from approved https://github.com/llvm/llvm-project/pull/186252
as suggested.

PR: https://github.com/llvm/llvm-project/pull/189352

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 8f937b2f8bc1f..7eefd77045050 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1637,9 +1637,11 @@ void VPPhi::execute(VPTransformState &State) {
   PHINode *NewPhi = State.Builder.CreatePHI(
       State.TypeAnalysis.inferScalarType(this), 2, getName());
   unsigned NumIncoming = getNumIncoming();
-  if (getParent() != getParent()->getPlan()->getScalarPreheader()) {
-    // TODO: Fixup all incoming values of header phis once recipes defining them
-    // are introduced.
+  // Detect header phis: the parent block dominates its second incoming block
+  // (the latch). Those IR incoming values have not been generated yet and need
+  // to be added after they have been executed.
+  if (NumIncoming == 2 &&
+      State.VPDT.dominates(getParent(), getIncomingBlock(1))) {
     NumIncoming = 1;
   }
   for (unsigned Idx = 0; Idx != NumIncoming; ++Idx) {


        


More information about the llvm-commits mailing list