[llvm] [LV] Return Invalid from getLegacyCost when instruction cost forced. (PR #154543)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 07:02:27 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);
----------------
david-arm wrote:
This is not a fault with your patch, but it looks like it was already broken due to this:
```
return InstructionCost(ForceTargetInstructionCost.getNumOccurrences());
```
I'm pretty sure it should be:
```
return InstructionCost(ForceTargetInstructionCost);
```
similar to `LoopVectorizationCostModel::expectedCost`
https://github.com/llvm/llvm-project/pull/154543
More information about the llvm-commits
mailing list