[llvm] [VPlan] Port invalid cost remarks to VPlan. (PR #99322)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 05:07:50 PDT 2024
================
@@ -4343,24 +4345,43 @@ bool LoopVectorizationPlanner::isMoreProfitable(
return CmpFn(RTCostA, RTCostB);
}
-static void emitInvalidCostRemarks(SmallVector<InstructionVFPair> InvalidCosts,
- OptimizationRemarkEmitter *ORE,
- Loop *TheLoop) {
+void LoopVectorizationPlanner::emitInvalidCostRemarks(
+ OptimizationRemarkEmitter *ORE) {
+ if (VPlans.empty())
+ return;
+
+ using RecipeVFPair = std::pair<VPRecipeBase *, ElementCount>;
+ SmallVector<RecipeVFPair> InvalidCosts;
+ for (const auto &Plan : VPlans) {
+ for (ElementCount VF : Plan->vectorFactors()) {
+ LLVMContext &LLVMCtx = OrigLoop->getHeader()->getContext();
+ VPCostContext CostCtx(CM.TTI, Legal->getWidestInductionType(), LLVMCtx,
+ CM);
+ auto Iter = vp_depth_first_deep(Plan->getVectorLoopRegion()->getEntry());
+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {
+ for (auto &R : *VPBB) {
+ if (R.cost(VF, CostCtx).isValid())
+ continue;
+ InvalidCosts.emplace_back(&R, VF);
+ }
+ }
+ }
+ }
if (InvalidCosts.empty())
return;
// Emit a report of VFs with invalid costs in the loop.
// Group the remarks per instruction, keeping the instruction order from
// InvalidCosts.
- std::map<Instruction *, unsigned> Numbering;
+ DenseMap<VPRecipeBase *, unsigned> Numbering;
unsigned I = 0;
for (auto &Pair : InvalidCosts)
if (!Numbering.count(Pair.first))
Numbering[Pair.first] = I++;
// Sort the list, first on instruction(number) then on VF.
----------------
fhahn wrote:
Done, thanks!
https://github.com/llvm/llvm-project/pull/99322
More information about the llvm-commits
mailing list