@@ -215,22 +215,23 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
215215 return InstructionCost::getInvalid ();
216216
217217 auto *VT = cast<FixedVectorType>(DataTy);
218+ unsigned VF = VT->getNumElements ();
219+
218220 // Assume the target does not have support for gather/scatter operations
219221 // and provide a rough estimate.
220222 //
221223 // First, compute the cost of the individual memory operations.
222224 InstructionCost AddrExtractCost =
223225 IsGatherScatter
224- ? getVectorInstrCost (Instruction::ExtractElement,
225- FixedVectorType::get (
226- PointerType ::get (VT-> getElementType (), 0 ),
227- VT->getNumElements () ),
228- CostKind, -1 , nullptr , nullptr )
226+ ? getVectorInstrCost (
227+ Instruction::ExtractElement,
228+ FixedVectorType ::get (
229+ PointerType::get ( VT->getElementType (), 0 ), VF ),
230+ CostKind, -1 , nullptr , nullptr )
229231 : 0 ;
230232 InstructionCost LoadCost =
231- VT->getNumElements () *
232- (AddrExtractCost +
233- getMemoryOpCost (Opcode, VT->getElementType (), Alignment, 0 , CostKind));
233+ VF * (AddrExtractCost + getMemoryOpCost (Opcode, VT->getElementType (),
234+ Alignment, 0 , CostKind));
234235
235236 // Next, compute the cost of packing the result in a vector.
236237 InstructionCost PackingCost =
@@ -246,11 +247,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
246247 // operations accurately is quite difficult and the current solution
247248 // provides a very rough estimate only.
248249 ConditionalCost =
249- VT-> getNumElements () *
250+ VF *
250251 (getVectorInstrCost (
251252 Instruction::ExtractElement,
252- FixedVectorType::get (Type::getInt1Ty (DataTy->getContext ()),
253- VT->getNumElements ()),
253+ FixedVectorType::get (Type::getInt1Ty (DataTy->getContext ()), VF),
254254 CostKind, -1 , nullptr , nullptr ) +
255255 getCFInstrCost (Instruction::Br, CostKind) +
256256 getCFInstrCost (Instruction::PHI, CostKind));
0 commit comments