[llvm] [VPlan] Simplify VPPhi with all-eq incoming (PR #190059)

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 09:00:54 PDT 2026


================
@@ -1645,15 +1645,14 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
     return;
   }
 
-  if (isa<VPPhi, VPWidenPHIRecipe, VPHeaderPHIRecipe>(Def)) {
-    if (Def->getNumOperands() == 1) {
-      Def->replaceAllUsesWith(Def->getOperand(0));
-      return;
-    }
-    if (auto *Phi = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(Def)) {
-      if (all_equal(Phi->incoming_values()))
-        Phi->replaceAllUsesWith(Phi->getOperand(0));
-    }
+  if (auto *Phi = dyn_cast<VPPhiAccessors>(Def)) {
+    // TODO: We cannot simplify all phis with all-eq incoming yet due to various
+    // incomplete phi constructions.
+    if ((isa<VPPhi, VPFirstOrderRecurrencePHIRecipe>(Def) &&
+         all_equal(Phi->incoming_values())) ||
+        (isa<VPWidenPHIRecipe, VPHeaderPHIRecipe>(Def) &&
+         Def->getNumOperands() == 1))
+      Def->replaceAllUsesWith(Phi->getIncomingValue(0));
----------------
eas wrote:

Feel free to ignore, unless Florian has preference for the more verbose one too.

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


More information about the llvm-commits mailing list