[llvm] [RISCV] Fix crash when unrolling loop containing vector instructions (PR #83384)
Shih-Po Hung via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 08:25:01 PST 2024
================
@@ -37,6 +37,9 @@ static cl::opt<unsigned> SLPMaxVF(
InstructionCost
RISCVTTIImpl::getRISCVInstructionCost(ArrayRef<unsigned> OpCodes, MVT VT,
TTI::TargetCostKind CostKind) {
+ // Check if the type is valid for all CostKind
+ if (!VT.isVector())
+ return InstructionCost::getInvalid();
----------------
arcbbb wrote:
It is from LoopUnrollPass along the way from TTI.getInstructionCost to TTI.getShuffleCost for
```
%splat.splat.i.i.i = shufflevector <2 x float> zeroinitializer, <2 x float> zeroinitializer, <2 x i32> zeroinitializer
```
The data type is `<2 x float>`, but becomes `float` after `getTypeLegalizationCost(Tp);` then enters getRISCVInstructionCost().
I'm just not sure how a vector type can be generated without a vector support.
If it is true, we might consider checking if the type is still vector after legalization at the beginning of TTI functions which accept vector types.
https://github.com/llvm/llvm-project/pull/83384
More information about the llvm-commits
mailing list