[llvm] [VPlan] Add vputils::reconstructSSA (PR #212209)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 02:39:07 PDT 2026
https://github.com/Mel-Chen commented:
Since this patch currently lacks landed real-world use cases, could we re-implement this block in `VPlanTransforms::foldTailByMasking`:
``` c++
// Insert phis for values coming past the end of the tail.
Builder.setInsertPoint(Latch, Latch->begin());
for (const auto &[V, Users] : NeedsPhi) {
if (isa<VPIRValue>(V))
continue;
VPValue *TailVal = Plan.getPoison(V->getScalarType());
VPIRFlags Flags;
assert(llvm::count_if(Users, IsaPred<VPReductionPHIRecipe>) <= 1 &&
"Value used by more than two reduction phis?");
auto *RedIt = find_if(Users, IsaPred<VPReductionPHIRecipe>);
auto *RdxPhi =
RedIt != Users.end() ? cast<VPReductionPHIRecipe>(*RedIt) : nullptr;
if (RdxPhi && !RdxPhi->isInLoop()) {
TailVal = RdxPhi;
Flags = *RdxPhi;
}
VPInstruction *Phi = Builder.createScalarPhi({V, TailVal}, {}, "", Flags);
for (VPUser *U : Users)
U->replaceUsesOfWith(V, Phi);
}
```
by `reconstructSSA({{OrigLatch, V}, {Header, TailVal}}, Latch)`?
https://github.com/llvm/llvm-project/pull/212209
More information about the llvm-commits
mailing list