[llvm] [VPlan] Don't use the legacy cost model for loop conditions (PR #156864)
John Brawn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 09:52:44 PST 2026
================
@@ -7204,6 +7174,55 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
});
});
}
+
+static bool planContainsDifferentCompares(VPlan &Plan, VPCostContext &CostCtx,
+ Loop *TheLoop, ElementCount VF) {
+ // Count how many compare instructions there are in the legacy cost model.
+ unsigned NumLegacyScalarCompares = 0, NumLegacyVectorCompares = 0;
+ for (BasicBlock *BB : TheLoop->blocks()) {
+ for (auto &I : *BB) {
+ if (isa<CmpInst>(I)) {
+ if (CostCtx.CM.isUniformAfterVectorization(&I, VF))
+ NumLegacyScalarCompares += 1;
+ else
+ NumLegacyVectorCompares += 1;
+ }
+ }
+ }
+
+ // Count how many compare instructions there are in the VPlan.
+ unsigned NumVPlanScalarCompares = 0, NumVPlanVectorCompares = 0;
+ VPRegionBlock *VectorRegion = Plan.getVectorLoopRegion();
+ auto Iter = vp_depth_first_deep(VectorRegion->getEntry());
----------------
john-brawn-arm wrote:
It looks like we don't, I've changed this to a shallow traversal.
https://github.com/llvm/llvm-project/pull/156864
More information about the llvm-commits
mailing list