[PATCH] D128937: [VPlan] Generalize VPWidenPHIRecipe to generate values for all parts.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 12:38:38 PDT 2022
fhahn created this revision.
Herald added subscribers: tschuett, psnobl, rogfer01, bollu, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added subscribers: llvm-commits, vkmr.
Herald added a project: LLVM.
This extends VPWidenPHIRecipe::execute to generate code for all parts.
This should allow using the recipe also in cases where vector phis are
needed for all parts, as in D125301 <https://reviews.llvm.org/D125301>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128937
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Index: llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -812,10 +812,13 @@
StartIdx = I;
}
}
- Value *Op0 = State.get(getOperand(StartIdx), 0);
- Type *VecTy = Op0->getType();
- Value *VecPhi = State.Builder.CreatePHI(VecTy, 2, "vec.phi");
- State.set(this, VecPhi, 0);
+ for (unsigned Part = 0, UF = State.UF; Part < UF; ++Part) {
+ Value *Start = State.get(getOperand(StartIdx), Part);
+ Type *VecTy = Start->getType();
+ PHINode *VecPhi = State.Builder.CreatePHI(VecTy, 2, "vec.phi");
+ VecPhi->addIncoming(Start, State.CFG.VPBB2IRBB[getIncomingBlock(StartIdx)]);
+ State.set(this, VecPhi, 0);
+ }
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4152,13 +4152,17 @@
VPWidenPHIRecipe *VPPhi = dyn_cast<VPWidenPHIRecipe>(&P);
if (!VPPhi)
continue;
- PHINode *NewPhi = cast<PHINode>(State.get(VPPhi, 0));
- // Make sure the builder has a valid insert point.
- Builder.SetInsertPoint(NewPhi);
- for (unsigned i = 0; i < VPPhi->getNumOperands(); ++i) {
- VPValue *Inc = VPPhi->getIncomingValue(i);
- VPBasicBlock *VPBB = VPPhi->getIncomingBlock(i);
- NewPhi->addIncoming(State.get(Inc, 0), State.CFG.VPBB2IRBB[VPBB]);
+ for (unsigned Part = 0, UF = State.UF; Part < UF; ++Part) {
+ PHINode *NewPhi = cast<PHINode>(State.get(VPPhi, Part));
+ // Make sure the builder has a valid insert point.
+ Builder.SetInsertPoint(NewPhi);
+ for (unsigned i = 0; i < VPPhi->getNumOperands(); ++i) {
+ VPValue *Inc = VPPhi->getIncomingValue(i);
+ BasicBlock *BB = State.CFG.VPBB2IRBB[VPPhi->getIncomingBlock(i)];
+ if (is_contained(NewPhi->blocks(), BB))
+ continue;
+ NewPhi->addIncoming(State.get(Inc, Part), BB);
+ }
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128937.441486.patch
Type: text/x-patch
Size: 2223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/299eddb1/attachment.bin>
More information about the llvm-commits
mailing list