[llvm] [VPlan] Remove loop region in optimizeForVFAndUF. (PR #108378)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 1 15:53:28 PST 2025
================
@@ -1069,19 +1069,28 @@ InstructionCost VPlan::cost(ElementCount VF, VPCostContext &Ctx) {
return getVectorLoopRegion()->cost(VF, Ctx);
}
+VPBasicBlock *VPlan::getVectorPreheader() {
+ VPBlockBase *Current = getEntry()->getSuccessors().back();
+ while (Current->getNumSuccessors() == 2)
+ Current = Current->getSuccessors().back();
+ return cast<VPBasicBlock>(Current);
+}
+
+VPBasicBlock *VPlan::getVectorPreheader() const {
+ VPBlockBase *Current = getEntry()->getSuccessors().back();
+ while (Current->getNumSuccessors() == 2)
+ Current = Current->getSuccessors().back();
+ return cast<VPBasicBlock>(Current);
+}
+
VPRegionBlock *VPlan::getVectorLoopRegion() {
// TODO: Cache if possible.
- for (VPBlockBase *B : vp_depth_first_shallow(getEntry()))
- if (auto *R = dyn_cast<VPRegionBlock>(B))
- return R;
- return nullptr;
+ return dyn_cast<VPRegionBlock>(getVectorPreheader()->getSingleSuccessor());
----------------
ayalz wrote:
Return null if this successor is a replicating region?
Can retain existing implementation which uses a shallow scan from entry, provided it also returns null if the first region found is replicating.
https://github.com/llvm/llvm-project/pull/108378
More information about the llvm-commits
mailing list