[llvm] [VPlan] Remove single-operand dead VPPhi (PR #156438)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 01:32:51 PDT 2025
================
@@ -561,17 +561,23 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
continue;
}
- // Check if R is a dead VPPhi <-> update cycle and remove it.
+ // Remove dead VPPhi <-> update cycles.
auto *PhiR = dyn_cast<VPPhi>(&R);
- if (!PhiR || PhiR->getNumOperands() != 2 || PhiR->getNumUsers() != 1)
+ if (!PhiR)
continue;
- VPValue *Incoming = PhiR->getOperand(1);
- if (*PhiR->user_begin() != Incoming->getDefiningRecipe() ||
- Incoming->getNumUsers() != 1)
- continue;
- PhiR->replaceAllUsesWith(PhiR->getOperand(0));
- PhiR->eraseFromParent();
- Incoming->getDefiningRecipe()->eraseFromParent();
+ if (PhiR->getNumOperands() == 1) {
+ PhiR->replaceAllUsesWith(PhiR->getOperand(0));
+ PhiR->eraseFromParent();
+ }
----------------
fhahn wrote:
Sure, for the improvements, it looks like we get those because all incoming values are the same, right? If that's the case, perhaps what is missing is s generalization of the fold in simplifyRecipes: instead of checking for single incoming value it could check if all incoming values are the same?
https://github.com/llvm/llvm-project/pull/156438
More information about the llvm-commits
mailing list