@@ -215,22 +215,23 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
215
215
return InstructionCost::getInvalid ();
216
216
217
217
auto *VT = cast<FixedVectorType>(DataTy);
218
+ unsigned VF = VT->getNumElements ();
219
+
218
220
// Assume the target does not have support for gather/scatter operations
219
221
// and provide a rough estimate.
220
222
//
221
223
// First, compute the cost of the individual memory operations.
222
224
InstructionCost AddrExtractCost =
223
225
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 )
229
231
: 0 ;
230
232
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));
234
235
235
236
// Next, compute the cost of packing the result in a vector.
236
237
InstructionCost PackingCost =
@@ -246,11 +247,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
246
247
// operations accurately is quite difficult and the current solution
247
248
// provides a very rough estimate only.
248
249
ConditionalCost =
249
- VT-> getNumElements () *
250
+ VF *
250
251
(getVectorInstrCost (
251
252
Instruction::ExtractElement,
252
- FixedVectorType::get (Type::getInt1Ty (DataTy->getContext ()),
253
- VT->getNumElements ()),
253
+ FixedVectorType::get (Type::getInt1Ty (DataTy->getContext ()), VF),
254
254
CostKind, -1 , nullptr , nullptr ) +
255
255
getCFInstrCost (Instruction::Br, CostKind) +
256
256
getCFInstrCost (Instruction::PHI, CostKind));
0 commit comments