To perform the cost model of vector casting, the patch consider most vector
casts as their scalar form and consider those vector form of free scalr castings
as 1.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I also want to handle scalable vector type. useRVVForFixedLengthVectors is used to make sure fixed vectors like v4i8 are legal. But I found that it is redundant for isTypeLegal testing.
The update removed useRVVForFixedLengthVectors() check since it is coverd by isTypeLegal() check and fixed the typo.
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | ||
---|---|---|
227 | Do you intend to use getTypeLegalizationCost to do this properly in the future? | |
244 | FP_TO_SINT/UINT is missing | |
246 | Is there any point in getting the scalar cost? Seems like its always 1 and doesn't have a real connection to how the vector ISA works. I'm also questioning the accuracy of some of the scalar numbers. i8->float requires a pair of shifts to clear the upper bits before doing an iXLen->float conversion for example. So if we were to fix that, it would be wrong for vectors. | |
llvm/test/Analysis/CostModel/RISCV/cast.ll | ||
121 | If you're going to test half vectors you should have +zfh on the command line | |
257 | How wrong are we intending the costs to be? This i8-float requires 2 vector instructions since the elements sizes are more than a factor of 2 apart. |
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | ||
---|---|---|
246 | My point to use scalar cost is just it is simple to implement and enough to make vectorizer think vectorizing casting instructions is profitable in most cases. I had written a version by vector instruction count. The logic is a little complex and I am not sure when to consider vsetvli and even lmul. I think maybe we should refine it to a table having some magic number like X86 and Arm, so I just provide the simple design now. |
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | ||
---|---|---|
246 | Please add a FIXME to document what is missing. |
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | ||
---|---|---|
227 | I think I should do it. But I am not sure how to do when the legalization costs are different between Dst and Src. I will also add FIXME here. |
Change the approach of cost model to caculate the vector casting counts.
I don't consider vsetvli in this patch, but it may cause not accurate cost
for multiple conversioin.
llvm/test/Analysis/CostModel/RISCV/cast.ll | ||
---|---|---|
3 | Need +experimental-zvfh |
Maybe check FixedVectorType rather than VectorType? I assume you only intend to handle fixed vector size since you checking useRVVForFixedLengthVectors here?