Skip to content

Commit f7d7d2a

Browse files
committed
Revert "Recommit "[SLP] Fix lookahead operand reordering for splat loads.""
This reverts commit 7961318. Causes crashes, see comments in https://reviews.llvm.org/D121973.
1 parent ccf8c96 commit f7d7d2a

23 files changed

+96
-237
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,6 @@ class TargetTransformInfo {
658658
/// Return true if the target supports nontemporal load.
659659
bool isLegalNTLoad(Type *DataType, Align Alignment) const;
660660

661-
/// \Returns true if the target supports broadcasting a load to a vector of
662-
/// type <NumElements x ElementTy>.
663-
bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const;
664-
665661
/// Return true if the target supports masked scatter.
666662
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const;
667663
/// Return true if the target supports masked gather.
@@ -1048,14 +1044,11 @@ class TargetTransformInfo {
10481044
/// The exact mask may be passed as Mask, or else the array will be empty.
10491045
/// The index and subtype parameters are used by the subvector insertion and
10501046
/// extraction shuffle kinds to show the insert/extract point and the type of
1051-
/// the subvector being inserted/extracted. The operands of the shuffle can be
1052-
/// passed through \p Args, which helps improve the cost estimation in some
1053-
/// cases, like in broadcast loads.
1047+
/// the subvector being inserted/extracted.
10541048
/// NOTE: For subvector extractions Tp represents the source type.
10551049
InstructionCost getShuffleCost(ShuffleKind Kind, VectorType *Tp,
10561050
ArrayRef<int> Mask = None, int Index = 0,
1057-
VectorType *SubTp = nullptr,
1058-
ArrayRef<Value *> Args = None) const;
1051+
VectorType *SubTp = nullptr) const;
10591052

10601053
/// Represents a hint about the context in which a cast is used.
10611054
///
@@ -1556,8 +1549,6 @@ class TargetTransformInfo::Concept {
15561549
virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment) = 0;
15571550
virtual bool isLegalNTStore(Type *DataType, Align Alignment) = 0;
15581551
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) = 0;
1559-
virtual bool isLegalBroadcastLoad(Type *ElementTy,
1560-
unsigned NumElements) const = 0;
15611552
virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) = 0;
15621553
virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) = 0;
15631554
virtual bool forceScalarizeMaskedGather(VectorType *DataType,
@@ -1668,8 +1659,7 @@ class TargetTransformInfo::Concept {
16681659
ArrayRef<const Value *> Args, const Instruction *CxtI = nullptr) = 0;
16691660
virtual InstructionCost getShuffleCost(ShuffleKind Kind, VectorType *Tp,
16701661
ArrayRef<int> Mask, int Index,
1671-
VectorType *SubTp,
1672-
ArrayRef<Value *> Args) = 0;
1662+
VectorType *SubTp) = 0;
16731663
virtual InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst,
16741664
Type *Src, CastContextHint CCH,
16751665
TTI::TargetCostKind CostKind,
@@ -1962,10 +1952,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
19621952
bool isLegalNTLoad(Type *DataType, Align Alignment) override {
19631953
return Impl.isLegalNTLoad(DataType, Alignment);
19641954
}
1965-
bool isLegalBroadcastLoad(Type *ElementTy,
1966-
unsigned NumElements) const override {
1967-
return Impl.isLegalBroadcastLoad(ElementTy, NumElements);
1968-
}
19691955
bool isLegalMaskedScatter(Type *DataType, Align Alignment) override {
19701956
return Impl.isLegalMaskedScatter(DataType, Alignment);
19711957
}
@@ -2193,9 +2179,8 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
21932179
}
21942180
InstructionCost getShuffleCost(ShuffleKind Kind, VectorType *Tp,
21952181
ArrayRef<int> Mask, int Index,
2196-
VectorType *SubTp,
2197-
ArrayRef<Value *> Args) override {
2198-
return Impl.getShuffleCost(Kind, Tp, Mask, Index, SubTp, Args);
2182+
VectorType *SubTp) override {
2183+
return Impl.getShuffleCost(Kind, Tp, Mask, Index, SubTp);
21992184
}
22002185
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
22012186
CastContextHint CCH,

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ class TargetTransformInfoImplBase {
256256
return Alignment >= DataSize && isPowerOf2_32(DataSize);
257257
}
258258

259-
bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const {
260-
return false;
261-
}
262-
263259
bool isLegalMaskedScatter(Type *DataType, Align Alignment) const {
264260
return false;
265261
}
@@ -492,8 +488,7 @@ class TargetTransformInfoImplBase {
492488

493489
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Ty,
494490
ArrayRef<int> Mask, int Index,
495-
VectorType *SubTp,
496-
ArrayRef<Value *> Args = None) const {
491+
VectorType *SubTp) const {
497492
return 1;
498493
}
499494

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
871871

872872
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
873873
ArrayRef<int> Mask, int Index,
874-
VectorType *SubTp,
875-
ArrayRef<Value *> Args = None) {
874+
VectorType *SubTp) {
876875

877876
switch (improveShuffleKindFromMask(Kind, Mask)) {
878877
case TTI::SK_Broadcast:

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,6 @@ bool TargetTransformInfo::isLegalNTLoad(Type *DataType, Align Alignment) const {
396396
return TTIImpl->isLegalNTLoad(DataType, Alignment);
397397
}
398398

399-
bool TargetTransformInfo::isLegalBroadcastLoad(Type *ElementTy,
400-
unsigned NumElements) const {
401-
return TTIImpl->isLegalBroadcastLoad(ElementTy, NumElements);
402-
}
403-
404399
bool TargetTransformInfo::isLegalMaskedGather(Type *DataType,
405400
Align Alignment) const {
406401
return TTIImpl->isLegalMaskedGather(DataType, Alignment);
@@ -745,11 +740,12 @@ InstructionCost TargetTransformInfo::getArithmeticInstrCost(
745740
return Cost;
746741
}
747742

748-
InstructionCost TargetTransformInfo::getShuffleCost(
749-
ShuffleKind Kind, VectorType *Ty, ArrayRef<int> Mask, int Index,
750-
VectorType *SubTp, ArrayRef<Value *> Args) const {
751-
InstructionCost Cost =
752-
TTIImpl->getShuffleCost(Kind, Ty, Mask, Index, SubTp, Args);
743+
InstructionCost TargetTransformInfo::getShuffleCost(ShuffleKind Kind,
744+
VectorType *Ty,
745+
ArrayRef<int> Mask,
746+
int Index,
747+
VectorType *SubTp) const {
748+
InstructionCost Cost = TTIImpl->getShuffleCost(Kind, Ty, Mask, Index, SubTp);
753749
assert(Cost >= 0 && "TTI should not produce negative costs!");
754750
return Cost;
755751
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,8 +2604,7 @@ InstructionCost AArch64TTIImpl::getSpliceCost(VectorType *Tp, int Index) {
26042604
InstructionCost AArch64TTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
26052605
VectorType *Tp,
26062606
ArrayRef<int> Mask, int Index,
2607-
VectorType *SubTp,
2608-
ArrayRef<Value *> Args) {
2607+
VectorType *SubTp) {
26092608
Kind = improveShuffleKindFromMask(Kind, Mask);
26102609
if (Kind == TTI::SK_Broadcast || Kind == TTI::SK_Transpose ||
26112610
Kind == TTI::SK_Select || Kind == TTI::SK_PermuteSingleSrc ||

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
330330

331331
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
332332
ArrayRef<int> Mask, int Index,
333-
VectorType *SubTp,
334-
ArrayRef<Value *> Args = None);
333+
VectorType *SubTp);
335334
/// @}
336335
};
337336

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,7 @@ Value *GCNTTIImpl::rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
10421042

10431043
InstructionCost GCNTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
10441044
VectorType *VT, ArrayRef<int> Mask,
1045-
int Index, VectorType *SubTp,
1046-
ArrayRef<Value *> Args) {
1045+
int Index, VectorType *SubTp) {
10471046
Kind = improveShuffleKindFromMask(Kind, Mask);
10481047
if (ST->hasVOP3PInsts()) {
10491048
if (cast<FixedVectorType>(VT)->getNumElements() == 2 &&

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
201201

202202
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
203203
ArrayRef<int> Mask, int Index,
204-
VectorType *SubTp,
205-
ArrayRef<Value *> Args = None);
204+
VectorType *SubTp);
206205

207206
bool areInlineCompatible(const Function *Caller,
208207
const Function *Callee) const;

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,7 @@ InstructionCost ARMTTIImpl::getMemcpyCost(const Instruction *I) {
12021202

12031203
InstructionCost ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
12041204
VectorType *Tp, ArrayRef<int> Mask,
1205-
int Index, VectorType *SubTp,
1206-
ArrayRef<Value *> Args) {
1205+
int Index, VectorType *SubTp) {
12071206
Kind = improveShuffleKindFromMask(Kind, Mask);
12081207
if (ST->hasNEON()) {
12091208
if (Kind == TTI::SK_Broadcast) {

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
213213

214214
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
215215
ArrayRef<int> Mask, int Index,
216-
VectorType *SubTp,
217-
ArrayRef<Value *> Args = None);
216+
VectorType *SubTp);
218217

219218
bool preferInLoopReduction(unsigned Opcode, Type *Ty,
220219
TTI::ReductionFlags Flags) const;

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ HexagonTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
223223

224224
InstructionCost HexagonTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
225225
ArrayRef<int> Mask, int Index,
226-
Type *SubTp,
227-
ArrayRef<Value *> Args) {
226+
Type *SubTp) {
228227
return 1;
229228
}
230229

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
125125
Align Alignment, unsigned AddressSpace,
126126
TTI::TargetCostKind CostKind);
127127
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
128-
ArrayRef<int> Mask, int Index, Type *SubTp,
129-
ArrayRef<Value *> Args = None);
128+
ArrayRef<int> Mask, int Index, Type *SubTp);
130129
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
131130
const Value *Ptr, bool VariableMask,
132131
Align Alignment,

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,7 @@ InstructionCost PPCTTIImpl::getArithmeticInstrCost(
10151015

10161016
InstructionCost PPCTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
10171017
ArrayRef<int> Mask, int Index,
1018-
Type *SubTp,
1019-
ArrayRef<Value *> Args) {
1018+
Type *SubTp) {
10201019

10211020
InstructionCost CostFactor =
10221021
vectorCostAdjustmentFactor(Instruction::ShuffleVector, Tp, nullptr);

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
111111
ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
112112
const Instruction *CxtI = nullptr);
113113
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
114-
ArrayRef<int> Mask, int Index, Type *SubTp,
115-
ArrayRef<Value *> Args = None);
114+
ArrayRef<int> Mask, int Index, Type *SubTp);
116115
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
117116
TTI::CastContextHint CCH,
118117
TTI::TargetCostKind CostKind,

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ InstructionCost RISCVTTIImpl::getSpliceCost(VectorType *Tp, int Index) {
175175

176176
InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
177177
VectorType *Tp, ArrayRef<int> Mask,
178-
int Index, VectorType *SubTp,
179-
ArrayRef<Value *> Args) {
178+
int Index, VectorType *SubTp) {
180179
if (Kind == TTI::SK_Splice && isa<ScalableVectorType>(Tp))
181180
return getSpliceCost(Tp, Index);
182181
return BaseT::getShuffleCost(Kind, Tp, Mask, Index, SubTp);

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
8080
InstructionCost getSpliceCost(VectorType *Tp, int Index);
8181
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
8282
ArrayRef<int> Mask, int Index,
83-
VectorType *SubTp,
84-
ArrayRef<Value *> Args = None);
83+
VectorType *SubTp);
8584

8685
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
8786
const Value *Ptr, bool VariableMask,

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,7 @@ InstructionCost SystemZTTIImpl::getArithmeticInstrCost(
559559
InstructionCost SystemZTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
560560
VectorType *Tp,
561561
ArrayRef<int> Mask, int Index,
562-
VectorType *SubTp,
563-
ArrayRef<Value *> Args) {
562+
VectorType *SubTp) {
564563
Kind = improveShuffleKindFromMask(Kind, Mask);
565564
if (ST->hasVector()) {
566565
unsigned NumVectors = getNumVectorRegs(Tp);

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
9292
const Instruction *CxtI = nullptr);
9393
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
9494
ArrayRef<int> Mask, int Index,
95-
VectorType *SubTp,
96-
ArrayRef<Value *> Args = None);
95+
VectorType *SubTp);
9796
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
9897
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
9998
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,7 @@ InstructionCost X86TTIImpl::getArithmeticInstrCost(
10851085
InstructionCost X86TTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
10861086
VectorType *BaseTp,
10871087
ArrayRef<int> Mask, int Index,
1088-
VectorType *SubTp,
1089-
ArrayRef<Value *> Args) {
1088+
VectorType *SubTp) {
10901089
// 64-bit packed float vectors (v2f32) are widened to type v4f32.
10911090
// 64-bit packed integer vectors (v2i32) are widened to type v4i32.
10921091
std::pair<InstructionCost, MVT> LT = TLI->getTypeLegalizationCost(DL, BaseTp);
@@ -1546,27 +1545,9 @@ InstructionCost X86TTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
15461545
{ TTI::SK_PermuteTwoSrc, MVT::v16i8, 13 }, // blend+permute
15471546
};
15481547

1549-
static const CostTblEntry SSE3BroadcastLoadTbl[] = {
1550-
{TTI::SK_Broadcast, MVT::v2f64, 0}, // broadcast handled by movddup
1551-
};
1552-
1553-
if (ST->hasSSE2()) {
1554-
bool IsLoad = !Args.empty() && llvm::all_of(Args, [](const Value *V) {
1555-
return isa<LoadInst>(V);
1556-
});
1557-
if (ST->hasSSE3() && IsLoad)
1558-
if (const auto *Entry =
1559-
CostTableLookup(SSE3BroadcastLoadTbl, Kind, LT.second)) {
1560-
assert(isLegalBroadcastLoad(
1561-
BaseTp->getElementType(),
1562-
cast<FixedVectorType>(BaseTp)->getNumElements()) &&
1563-
"Table entry missing from isLegalBroadcastLoad()");
1564-
return LT.first * Entry->Cost;
1565-
}
1566-
1548+
if (ST->hasSSE2())
15671549
if (const auto *Entry = CostTableLookup(SSE2ShuffleTbl, Kind, LT.second))
15681550
return LT.first * Entry->Cost;
1569-
}
15701551

15711552
static const CostTblEntry SSE1ShuffleTbl[] = {
15721553
{ TTI::SK_Broadcast, MVT::v4f32, 1 }, // shufps
@@ -5137,13 +5118,6 @@ bool X86TTIImpl::isLegalNTStore(Type *DataType, Align Alignment) {
51375118
return true;
51385119
}
51395120

5140-
bool X86TTIImpl::isLegalBroadcastLoad(Type *ElementTy,
5141-
unsigned NumElements) const {
5142-
// movddup
5143-
return ST->hasSSSE3() && NumElements == 2 &&
5144-
ElementTy == Type::getDoubleTy(ElementTy->getContext());
5145-
}
5146-
51475121
bool X86TTIImpl::isLegalMaskedExpandLoad(Type *DataTy) {
51485122
if (!isa<VectorType>(DataTy))
51495123
return false;

llvm/lib/Target/X86/X86TargetTransformInfo.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
131131
const Instruction *CxtI = nullptr);
132132
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
133133
ArrayRef<int> Mask, int Index,
134-
VectorType *SubTp,
135-
ArrayRef<Value *> Args = None);
134+
VectorType *SubTp);
136135
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
137136
TTI::CastContextHint CCH,
138137
TTI::TargetCostKind CostKind,
@@ -227,7 +226,6 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
227226
bool isLegalMaskedStore(Type *DataType, Align Alignment);
228227
bool isLegalNTLoad(Type *DataType, Align Alignment);
229228
bool isLegalNTStore(Type *DataType, Align Alignment);
230-
bool isLegalBroadcastLoad(Type *ElementTy, unsigned NumElements) const;
231229
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment);
232230
bool forceScalarizeMaskedScatter(VectorType *VTy, Align Alignment) {
233231
return forceScalarizeMaskedGather(VTy, Alignment);

0 commit comments

Comments
 (0)