[llvm] [VPlan] Don't use the legacy cost model for loop conditions (PR #156864)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 03:48:37 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());
----------------
fhahn wrote:
do we need a deep traversal, i.e. do we have test cases where we conditionally execute compares in replicate regions?
https://github.com/llvm/llvm-project/pull/156864
More information about the llvm-commits
mailing list