@@ -34,28 +34,6 @@ static cl::opt<unsigned> SLPMaxVF(
34
34
" exclusively by SLP vectorizer." ),
35
35
cl::Hidden);
36
36
37
- InstructionCost RISCVTTIImpl::getLMULCost (MVT VT) const {
38
- // TODO: Here assume reciprocal throughput is 1 for LMUL_1, it is
39
- // implementation-defined.
40
- if (!VT.isVector ())
41
- return InstructionCost::getInvalid ();
42
- unsigned DLenFactor = ST->getDLenFactor ();
43
- unsigned Cost;
44
- if (VT.isScalableVector ()) {
45
- unsigned LMul;
46
- bool Fractional;
47
- std::tie (LMul, Fractional) =
48
- RISCVVType::decodeVLMUL (RISCVTargetLowering::getLMUL (VT));
49
- if (Fractional)
50
- Cost = LMul <= DLenFactor ? (DLenFactor / LMul) : 1 ;
51
- else
52
- Cost = (LMul * DLenFactor);
53
- } else {
54
- Cost = divideCeil (VT.getSizeInBits (), ST->getRealMinVLen () / DLenFactor);
55
- }
56
- return Cost;
57
- }
58
-
59
37
InstructionCost RISCVTTIImpl::getIntImmCost (const APInt &Imm, Type *Ty,
60
38
TTI::TargetCostKind CostKind) {
61
39
assert (Ty->isIntegerTy () &&
@@ -263,28 +241,6 @@ static VectorType *getVRGatherIndexType(MVT DataVT, const RISCVSubtarget &ST,
263
241
return cast<VectorType>(EVT (IndexVT).getTypeForEVT (C));
264
242
}
265
243
266
- // / Return the cost of a vrgather.vv instruction for the type VT. vrgather.vv
267
- // / is generally quadratic in the number of vreg implied by LMUL. Note that
268
- // / operand (index and possibly mask) are handled separately.
269
- InstructionCost RISCVTTIImpl::getVRGatherVVCost (MVT VT) const {
270
- return getLMULCost (VT) * getLMULCost (VT);
271
- }
272
-
273
- // / Return the cost of a vrgather.vi (or vx) instruction for the type VT.
274
- // / vrgather.vi/vx may be linear in the number of vregs implied by LMUL,
275
- // / or may track the vrgather.vv cost. It is implementation-dependent.
276
- InstructionCost RISCVTTIImpl::getVRGatherVICost (MVT VT) const {
277
- return getLMULCost (VT);
278
- }
279
-
280
- // / Return the cost of a vslidedown.vi/vx or vslideup.vi/vx instruction
281
- // / for the type VT. (This does not cover the vslide1up or vslide1down
282
- // / variants.) Slides may be linear in the number of vregs implied by LMUL,
283
- // / or may track the vrgather.vv cost. It is implementation-dependent.
284
- InstructionCost RISCVTTIImpl::getVSlideCost (MVT VT) const {
285
- return getLMULCost (VT);
286
- }
287
-
288
244
InstructionCost RISCVTTIImpl::getShuffleCost (TTI::ShuffleKind Kind,
289
245
VectorType *Tp, ArrayRef<int > Mask,
290
246
TTI::TargetCostKind CostKind,
@@ -314,14 +270,14 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
314
270
// li a0, -1 (ignored)
315
271
// vwmaccu.vx v10, a0, v9
316
272
if (ShuffleVectorInst::isInterleaveMask (Mask, 2 , Mask.size ()))
317
- return 2 * LT.first * getLMULCost (LT.second );
273
+ return 2 * LT.first * TLI-> getLMULCost (LT.second );
318
274
319
275
if (Mask[0 ] == 0 || Mask[0 ] == 1 ) {
320
276
auto DeinterleaveMask = createStrideMask (Mask[0 ], 2 , Mask.size ());
321
277
// Example sequence:
322
278
// vnsrl.wi v10, v8, 0
323
279
if (equal (DeinterleaveMask, Mask))
324
- return LT.first * getLMULCost (LT.second );
280
+ return LT.first * TLI-> getLMULCost (LT.second );
325
281
}
326
282
}
327
283
}
@@ -332,7 +288,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
332
288
LT.second .getVectorNumElements () <= 256 )) {
333
289
VectorType *IdxTy = getVRGatherIndexType (LT.second , *ST, Tp->getContext ());
334
290
InstructionCost IndexCost = getConstantPoolLoadCost (IdxTy, CostKind);
335
- return IndexCost + getVRGatherVVCost (LT.second );
291
+ return IndexCost + TLI-> getVRGatherVVCost (LT.second );
336
292
}
337
293
[[fallthrough]];
338
294
}
@@ -350,7 +306,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
350
306
VectorType *MaskTy = VectorType::get (IntegerType::getInt1Ty (C), EC);
351
307
InstructionCost IndexCost = getConstantPoolLoadCost (IdxTy, CostKind);
352
308
InstructionCost MaskCost = getConstantPoolLoadCost (MaskTy, CostKind);
353
- return 2 * IndexCost + 2 * getVRGatherVVCost (LT.second ) + MaskCost;
309
+ return 2 * IndexCost + 2 * TLI-> getVRGatherVVCost (LT.second ) + MaskCost;
354
310
}
355
311
[[fallthrough]];
356
312
}
@@ -402,19 +358,19 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
402
358
// Example sequence:
403
359
// vsetivli zero, 4, e8, mf2, tu, ma (ignored)
404
360
// vslidedown.vi v8, v9, 2
405
- return LT.first * getVSlideCost (LT.second );
361
+ return LT.first * TLI-> getVSlideCost (LT.second );
406
362
case TTI::SK_InsertSubvector:
407
363
// Example sequence:
408
364
// vsetivli zero, 4, e8, mf2, tu, ma (ignored)
409
365
// vslideup.vi v8, v9, 2
410
- return LT.first * getVSlideCost (LT.second );
366
+ return LT.first * TLI-> getVSlideCost (LT.second );
411
367
case TTI::SK_Select: {
412
368
// Example sequence:
413
369
// li a0, 90
414
370
// vsetivli zero, 8, e8, mf2, ta, ma (ignored)
415
371
// vmv.s.x v0, a0
416
372
// vmerge.vvm v8, v9, v8, v0
417
- return LT.first * 3 * getLMULCost (LT.second );
373
+ return LT.first * 3 * TLI-> getLMULCost (LT.second );
418
374
}
419
375
case TTI::SK_Broadcast: {
420
376
bool HasScalar = (Args.size () > 0 ) && (Operator::getOpcode (Args[0 ]) ==
@@ -426,7 +382,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
426
382
// vsetivli zero, 2, e8, mf8, ta, ma (ignored)
427
383
// vmv.v.x v8, a0
428
384
// vmsne.vi v0, v8, 0
429
- return LT.first * getLMULCost (LT.second ) * 3 ;
385
+ return LT.first * TLI-> getLMULCost (LT.second ) * 3 ;
430
386
}
431
387
// Example sequence:
432
388
// vsetivli zero, 2, e8, mf8, ta, mu (ignored)
@@ -437,24 +393,24 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
437
393
// vmv.v.x v8, a0
438
394
// vmsne.vi v0, v8, 0
439
395
440
- return LT.first * getLMULCost (LT.second ) * 6 ;
396
+ return LT.first * TLI-> getLMULCost (LT.second ) * 6 ;
441
397
}
442
398
443
399
if (HasScalar) {
444
400
// Example sequence:
445
401
// vmv.v.x v8, a0
446
- return LT.first * getLMULCost (LT.second );
402
+ return LT.first * TLI-> getLMULCost (LT.second );
447
403
}
448
404
449
405
// Example sequence:
450
406
// vrgather.vi v9, v8, 0
451
- return LT.first * getVRGatherVICost (LT.second );
407
+ return LT.first * TLI-> getVRGatherVICost (LT.second );
452
408
}
453
409
case TTI::SK_Splice:
454
410
// vslidedown+vslideup.
455
411
// TODO: Multiplying by LT.first implies this legalizes into multiple copies
456
412
// of similar code, but I think we expand through memory.
457
- return 2 * LT.first * getVSlideCost (LT.second );
413
+ return 2 * LT.first * TLI-> getVSlideCost (LT.second );
458
414
case TTI::SK_Reverse: {
459
415
// TODO: Cases to improve here:
460
416
// * Illegal vector types
@@ -474,7 +430,7 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
474
430
if (LT.second .isFixedLengthVector ())
475
431
// vrsub.vi has a 5 bit immediate field, otherwise an li suffices
476
432
LenCost = isInt<5 >(LT.second .getVectorNumElements () - 1 ) ? 0 : 1 ;
477
- InstructionCost GatherCost = 2 + getVRGatherVVCost (LT.second );
433
+ InstructionCost GatherCost = 2 + TLI-> getVRGatherVVCost (LT.second );
478
434
// Mask operation additionally required extend and truncate
479
435
InstructionCost ExtendCost = Tp->getElementType ()->isIntegerTy (1 ) ? 3 : 0 ;
480
436
return LT.first * (LenCost + GatherCost + ExtendCost);
@@ -1393,7 +1349,7 @@ InstructionCost RISCVTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
1393
1349
// handles the LT.first term for us.
1394
1350
if (std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost (Src);
1395
1351
LT.second .isVector ())
1396
- BaseCost *= getLMULCost (LT.second );
1352
+ BaseCost *= TLI-> getLMULCost (LT.second );
1397
1353
return Cost + BaseCost;
1398
1354
1399
1355
}
@@ -1641,7 +1597,7 @@ InstructionCost RISCVTTIImpl::getArithmeticInstrCost(
1641
1597
case ISD::FSUB:
1642
1598
case ISD::FMUL:
1643
1599
case ISD::FNEG: {
1644
- return ConstantMatCost + getLMULCost (LT.second ) * LT.first * 1 ;
1600
+ return ConstantMatCost + TLI-> getLMULCost (LT.second ) * LT.first * 1 ;
1645
1601
}
1646
1602
default :
1647
1603
return ConstantMatCost +
0 commit comments