[llvm] [LV] Fix incorrect cost kind in VPReplicateRecipe::computeCost (PR #153216)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 14 05:02:00 PDT 2025
david-arm wrote:
> > > Thanks. Would be great to have a test case for this. I can check if I can surface anything
> >
> >
> > I don't think this is even possible at the moment, because this will currently only apply if you build with `-Oz -fvectorize`, but you can't even write a test case for this because we hit the error at the end of `LoopVectorizationCostModel::computeMaxVF`:
> > ```
> > reportVectorizationFailure(
> > "Cannot optimize for size and vectorize at the same time.",
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > I suppose that really means this patch is NFC and should be harmless. I just wanted to change the CostKind for completeness.
>
> Hm, I think we should definitely hit VPReplicateRecipe::computeCost with different CostKinds, e.g. for this test https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/LoopVectorize/AArch64/optsize_minsize.ll#L221
>
> For Os/Oz, the requirement is that there is no scalar tail + no runtime checks IIRC, and the message is for that case.
Nope, we never create replicate recipes at all due to this from the debug output:
```
LV: Not considering vector loop of width 2 because it would cause replicated blocks to be generated, which isn't allowed when optimizing for size.
LV: Not considering vector loop of width 4 because it would cause replicated blocks to be generated, which isn't allowed when optimizing for size.
LV: Not considering vector loop of width 8 because it would cause replicated blocks to be generated, which isn't allowed when optimizing for size.
LV: Not considering vector loop of width 16 because it would cause replicated blocks to be generated, which isn't allowed when optimizing for size.
```
https://github.com/llvm/llvm-project/pull/153216
More information about the llvm-commits
mailing list