[llvm] [LV] Return Invalid from getLegacyCost when instruction cost forced. (PR #154543)

Kerry McLaughlin via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 07:29:33 PDT 2025


================
@@ -6760,9 +6760,10 @@ void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
 
 InstructionCost VPCostContext::getLegacyCost(Instruction *UI,
                                              ElementCount VF) const {
-  if (ForceTargetInstructionCost.getNumOccurrences())
+  InstructionCost Cost = CM.getInstructionCost(UI, VF);
+  if (Cost.isValid() && ForceTargetInstructionCost.getNumOccurrences())
     return InstructionCost(ForceTargetInstructionCost.getNumOccurrences());
-  return CM.getInstructionCost(UI, VF);
----------------
kmclaughlin-arm wrote:

I think you're right, it should be `ForceTargetInstructionCost`. I've updated this in the latest commit.

https://github.com/llvm/llvm-project/pull/154543


More information about the llvm-commits mailing list