[llvm] df54a2d - [VPlan] Only skip induction phis in planContainsAdditionalSimps (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 15 11:35:06 PDT 2025
Author: Florian Hahn
Date: 2025-06-15T19:31:30+01:00
New Revision: df54a2d9357fe7f56ca3c6fa2f07889449b50325
URL: https://github.com/llvm/llvm-project/commit/df54a2d9357fe7f56ca3c6fa2f07889449b50325
DIFF: https://github.com/llvm/llvm-project/commit/df54a2d9357fe7f56ca3c6fa2f07889449b50325.diff
LOG: [VPlan] Only skip induction phis in planContainsAdditionalSimps (NFC).
Skip induction phis when checking for simplifications, as they may not
be lowered directly be lowered to a corresponding PHI recipe. Reductions
and first-order recurrences will get lowered to phi recipes, unless they
are removed. Considering them for simplifications allows removing them
if there are no remaining users.
NFC as currently reduction and recurrence phis are not
simplified/removed if dead.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9b5ad16589539..eb04e2d5ca7b4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7061,7 +7061,10 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx,
TheLoop](BasicBlock *BB) {
return any_of(*BB, [&SeenInstrs, &CostCtx, TheLoop, BB](Instruction &I) {
- if (isa<PHINode>(&I) && BB == TheLoop->getHeader())
+ // Skip induction phis when checking for simplifications, as they may not
+ // be lowered directly be lowered to a corresponding PHI recipe.
+ if (isa<PHINode>(&I) && BB == TheLoop->getHeader() &&
+ CostCtx.CM.Legal->isInductionPhi(cast<PHINode>(&I)))
return false;
return !SeenInstrs.contains(&I) && !CostCtx.skipCostComputation(&I, true);
});
More information about the llvm-commits
mailing list