@@ -1989,22 +1989,23 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
1989
1989
Type *ScalarType = Val->getScalarType ();
1990
1990
Align VecAlign = DL.getPrefTypeAlign (Val);
1991
1991
Align SclAlign = DL.getPrefTypeAlign (ScalarType);
1992
+ // Extra addi for unknown index.
1993
+ InstructionCost IdxCost = Index == -1U ? 1 : 0 ;
1992
1994
1993
1995
// Store all split vectors into stack and load the target element.
1994
1996
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) +
1997
1998
getMemoryOpCost (Instruction::Load, ScalarType, SclAlign, 0 ,
1998
- CostKind);
1999
+ CostKind) +
2000
+ IdxCost;
1999
2001
2000
2002
// Store all split vectors into stack and store the target element and load
2001
2003
// 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) +
2006
2006
getMemoryOpCost (Instruction::Store, ScalarType, SclAlign, 0 ,
2007
- CostKind);
2007
+ CostKind) +
2008
+ IdxCost;
2008
2009
}
2009
2010
2010
2011
// Extract i64 in the target that has XLEN=32 need more instruction.
@@ -2030,7 +2031,6 @@ InstructionCost RISCVTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
2030
2031
// TODO: should we count these special vsetvlis?
2031
2032
BaseCost = Opcode == Instruction::InsertElement ? 3 : 4 ;
2032
2033
}
2033
-
2034
2034
return BaseCost + SlideCost;
2035
2035
}
2036
2036
0 commit comments