[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 Oct 27 20:22:49 PDT 2025
================
@@ -6988,6 +6948,35 @@ 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 NumLegacyCompares = 0;
+ for (BasicBlock *BB : TheLoop->blocks()) {
+ for (auto &I : *BB) {
+ if (isa<CmpInst>(I)) {
+ NumLegacyCompares += 1;
+ }
+ }
+ }
+
+ // Count how many compare instructions there are in the VPlan.
+ unsigned NumVPlanCompares = 0;
+ auto Iter = vp_depth_first_deep(Plan.getVectorLoopRegion()->getEntry());
+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {
----------------
fhahn wrote:
> planContainsDifferentCompares would count 1 compare in the legacy cost model, no compares in the vplan, and return true.
Yep, what I was wondering was if we could exclude plans with ActiveLaneMask terminated exiting blocks from the carve-out, to preserve the original check for those?
https://github.com/llvm/llvm-project/pull/156864
More information about the llvm-commits
mailing list