@@ -1989,22 +1989,23 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
19891989 Type *ScalarType = Val->getScalarType ();
19901990 Align VecAlign = DL.getPrefTypeAlign (Val);
19911991 Align SclAlign = DL.getPrefTypeAlign (ScalarType);
1992+ // Extra addi for unknown index.
1993+ InstructionCost IdxCost = Index == -1U ? 1 : 0 ;
19921994
19931995 // Store all split vectors into stack and load the target element.
19941996 if (Opcode == Instruction::ExtractElement)
1995- return LT.first * getMemoryOpCost (Instruction::Store, Val, VecAlign, 0 ,
1996- CostKind) +
1997+ return getMemoryOpCost (Instruction::Store, Val, VecAlign, 0 , CostKind) +
19971998 getMemoryOpCost (Instruction::Load, ScalarType, SclAlign, 0 ,
1998- CostKind);
1999+ CostKind) +
2000+ IdxCost;
19992001
20002002 // Store all split vectors into stack and store the target element and load
20012003 // vectors back.
2002- return LT.first * (getMemoryOpCost (Instruction::Store, Val, VecAlign, 0 ,
2003- CostKind) +
2004- getMemoryOpCost (Instruction::Load, Val, VecAlign, 0 ,
2005- CostKind)) +
2004+ return getMemoryOpCost (Instruction::Store, Val, VecAlign, 0 , CostKind) +
2005+ getMemoryOpCost (Instruction::Load, Val, VecAlign, 0 , CostKind) +
20062006 getMemoryOpCost (Instruction::Store, ScalarType, SclAlign, 0 ,
2007- CostKind);
2007+ CostKind) +
2008+ IdxCost;
20082009 }
20092010
20102011 // Extract i64 in the target that has XLEN=32 need more instruction.
@@ -2030,7 +2031,6 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
20302031 // TODO: should we count these special vsetvlis?
20312032 BaseCost = Opcode == Instruction::InsertElement ? 3 : 4 ;
20322033 }
2033-
20342034 return BaseCost + SlideCost;
20352035}
20362036
0 commit comments