Skip to content

Commit 6753d0e

Browse files
committed
resolve review comments
update DeadInst vec on successful transformation only Change-Id: I920357d090960b84c46648666eca033033f209a3
1 parent b67e3f7 commit 6753d0e

File tree

4 files changed

+46
-48
lines changed

4 files changed

+46
-48
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3169,7 +3169,7 @@ class TargetLoweringBase {
31693169
/// \p SI is the accompanying store instruction
31703170
virtual bool lowerInterleaveIntrinsicToStore(
31713171
IntrinsicInst *II, StoreInst *SI,
3172-
SmallVectorImpl<Instruction *> &DeadInstructions) const {
3172+
SmallVectorImpl<Instruction *> &DeadInsts) const {
31733173
return false;
31743174
}
31753175

llvm/lib/CodeGen/InterleavedAccessPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ bool InterleavedAccessImpl::lowerInterleaveIntrinsic(
510510

511511
LLVM_DEBUG(dbgs() << "IA: Found an interleave intrinsic: " << *II << "\n");
512512

513-
SmallVector<Instruction *, 32> InterleaveDeadInsts;
513+
SmallVector<Instruction *, 4> InterleaveDeadInsts;
514514
// Try and match this with target specific intrinsics.
515515
if (!TLI->lowerInterleaveIntrinsicToStore(II, SI, InterleaveDeadInsts))
516516
return false;

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16906,9 +16906,9 @@ bool AArch64TargetLowering::lowerInterleavedStore(StoreInst *SI,
1690616906
return true;
1690716907
}
1690816908

16909-
bool getDeinterleave2Values(Value *DI,
16910-
SmallVectorImpl<Instruction *> &DeinterleavedValues,
16911-
SmallVectorImpl<Instruction *> &DeadInsts) {
16909+
bool getDeinterleave2Values(
16910+
Value *DI, SmallVectorImpl<Instruction *> &DeinterleavedValues,
16911+
SmallVectorImpl<Instruction *> &DeInterleaveDeadInsts) {
1691216912
if (!DI->hasNUses(2))
1691316913
return false;
1691416914
auto *Extr1 = dyn_cast<ExtractValueInst>(*(DI->user_begin()));
@@ -16930,8 +16930,9 @@ bool getDeinterleave2Values(Value *DI,
1693016930
return false;
1693116931
}
1693216932
// DeinterleavedValues will be replace by output of ld2
16933-
DeadInsts.insert(DeadInsts.end(), DeinterleavedValues.begin(),
16934-
DeinterleavedValues.end());
16933+
DeInterleaveDeadInsts.insert(DeInterleaveDeadInsts.end(),
16934+
DeinterleavedValues.begin(),
16935+
DeinterleavedValues.end());
1693516936
return true;
1693616937
}
1693716938

@@ -16952,9 +16953,9 @@ vector.deinterleave4 intrinsic. When true is returned, `DeinterleavedValues`
1695216953
vector is populated with the results such an intrinsic would return: (i.e. {A,
1695316954
B, C, D } = vector.deinterleave4(...))
1695416955
*/
16955-
bool getDeinterleave4Values(Value *DI,
16956-
SmallVectorImpl<Instruction *> &DeinterleavedValues,
16957-
SmallVectorImpl<Instruction *> &DeadInsts) {
16956+
bool getDeinterleave4Values(
16957+
Value *DI, SmallVectorImpl<Instruction *> &DeinterleavedValues,
16958+
SmallVectorImpl<Instruction *> &DeInterleaveDeadInsts) {
1695816959
if (!DI->hasNUses(2))
1695916960
return false;
1696016961
auto *Extr1 = dyn_cast<ExtractValueInst>(*(DI->user_begin()));
@@ -17008,22 +17009,23 @@ bool getDeinterleave4Values(Value *DI,
1700817009

1700917010
// These Values will not be used anymore,
1701017011
// DI4 will be created instead of nested DI1 and DI2
17011-
DeadInsts.insert(DeadInsts.end(), DeinterleavedValues.begin(),
17012-
DeinterleavedValues.end());
17013-
DeadInsts.push_back(cast<Instruction>(DI1));
17014-
DeadInsts.push_back(cast<Instruction>(Extr1));
17015-
DeadInsts.push_back(cast<Instruction>(DI2));
17016-
DeadInsts.push_back(cast<Instruction>(Extr2));
17012+
DeInterleaveDeadInsts.insert(DeInterleaveDeadInsts.end(),
17013+
DeinterleavedValues.begin(),
17014+
DeinterleavedValues.end());
17015+
DeInterleaveDeadInsts.push_back(cast<Instruction>(DI1));
17016+
DeInterleaveDeadInsts.push_back(cast<Instruction>(Extr1));
17017+
DeInterleaveDeadInsts.push_back(cast<Instruction>(DI2));
17018+
DeInterleaveDeadInsts.push_back(cast<Instruction>(Extr2));
1701717019

1701817020
return true;
1701917021
}
1702017022

17021-
bool getDeinterleavedValues(Value *DI,
17022-
SmallVectorImpl<Instruction *> &DeinterleavedValues,
17023-
SmallVectorImpl<Instruction *> &DeadInsts) {
17024-
if (getDeinterleave4Values(DI, DeinterleavedValues, DeadInsts))
17023+
bool getDeinterleavedValues(
17024+
Value *DI, SmallVectorImpl<Instruction *> &DeinterleavedValues,
17025+
SmallVectorImpl<Instruction *> &DeInterleaveDeadInsts) {
17026+
if (getDeinterleave4Values(DI, DeinterleavedValues, DeInterleaveDeadInsts))
1702517027
return true;
17026-
return getDeinterleave2Values(DI, DeinterleavedValues, DeadInsts);
17028+
return getDeinterleave2Values(DI, DeinterleavedValues, DeInterleaveDeadInsts);
1702717029
}
1702817030

1702917031
bool AArch64TargetLowering::lowerDeinterleaveIntrinsicToLoad(
@@ -17034,9 +17036,9 @@ bool AArch64TargetLowering::lowerDeinterleaveIntrinsicToLoad(
1703417036
return false;
1703517037

1703617038
SmallVector<Instruction *, 4> DeinterleavedValues;
17037-
const DataLayout &DL = DI->getModule()->getDataLayout();
17039+
SmallVector<Instruction *, 4> DeInterleaveDeadInsts;
1703817040

17039-
if (!getDeinterleavedValues(DI, DeinterleavedValues, DeadInsts)) {
17041+
if (!getDeinterleavedValues(DI, DeinterleavedValues, DeInterleaveDeadInsts)) {
1704017042
LLVM_DEBUG(dbgs() << "Matching ld2 and ld4 patterns failed\n");
1704117043
return false;
1704217044
}
@@ -17045,18 +17047,15 @@ bool AArch64TargetLowering::lowerDeinterleaveIntrinsicToLoad(
1704517047
"Currently supported Factor is 2 or 4 only");
1704617048
VectorType *VTy = cast<VectorType>(DeinterleavedValues[0]->getType());
1704717049

17050+
const DataLayout &DL = DI->getModule()->getDataLayout();
1704817051
bool UseScalable;
17049-
if (!isLegalInterleavedAccessType(VTy, DL, UseScalable)) {
17050-
DeadInsts.clear();
17052+
if (!isLegalInterleavedAccessType(VTy, DL, UseScalable))
1705117053
return false;
17052-
}
1705317054

1705417055
// TODO: Add support for using SVE instructions with fixed types later, using
1705517056
// the code from lowerInterleavedLoad to obtain the correct container type.
17056-
if (UseScalable && !VTy->isScalableTy()) {
17057-
DeadInsts.clear();
17057+
if (UseScalable && !VTy->isScalableTy())
1705817058
return false;
17059-
}
1706017059

1706117060
unsigned NumLoads = getNumInterleavedAccesses(VTy, DL, UseScalable);
1706217061
VectorType *LdTy =
@@ -17094,7 +17093,7 @@ bool AArch64TargetLowering::lowerDeinterleaveIntrinsicToLoad(
1709417093
}
1709517094
LLVM_DEBUG(dbgs() << "LdN4 res: "; LdN->dump());
1709617095
}
17097-
// Replcae output of deinterleave2 intrinsic by output of ldN2/ldN4
17096+
// Replace output of deinterleave2 intrinsic by output of ldN2/ldN4
1709817097
for (unsigned J = 0; J < Factor; ++J)
1709917098
DeinterleavedValues[J]->replaceAllUsesWith(ExtractedLdValues[J]);
1710017099
} else {
@@ -17103,12 +17102,14 @@ bool AArch64TargetLowering::lowerDeinterleaveIntrinsicToLoad(
1710317102
Result = Builder.CreateCall(LdNFunc, {Pred, BaseAddr}, "ldN");
1710417103
else
1710517104
Result = Builder.CreateCall(LdNFunc, BaseAddr, "ldN");
17106-
// Replcae output of deinterleave2 intrinsic by output of ldN2/ldN4
17105+
// Replace output of deinterleave2 intrinsic by output of ldN2/ldN4
1710717106
for (unsigned I = 0; I < DeinterleavedValues.size(); I++) {
1710817107
Value *NewExtract = Builder.CreateExtractValue(Result, I);
1710917108
DeinterleavedValues[I]->replaceAllUsesWith(NewExtract);
1711017109
}
1711117110
}
17111+
DeadInsts.insert(DeadInsts.end(), DeInterleaveDeadInsts.begin(),
17112+
DeInterleaveDeadInsts.end());
1711217113
return true;
1711317114
}
1711417115

@@ -17126,9 +17127,9 @@ vector.interleave4 intrinsic. When true is returned, `ValuesToInterleave` vector
1712617127
is populated with the inputs such an intrinsic would take: (i.e.
1712717128
vector.interleave4(A, B, C, D)).
1712817129
*/
17129-
bool getValuesToInterleave(Value *II,
17130-
SmallVectorImpl<Value *> &ValuesToInterleave,
17131-
SmallVectorImpl<Instruction *> &DeadInsts) {
17130+
bool getValuesToInterleave(
17131+
Value *II, SmallVectorImpl<Value *> &ValuesToInterleave,
17132+
SmallVectorImpl<Instruction *> &InterleaveDeadInsts) {
1713217133
Value *A, *B, *C, *D;
1713317134
// Try to match interleave of Factor 4
1713417135
if (match(II, m_Interleave2(m_Interleave2(m_Value(A), m_Value(C)),
@@ -17138,11 +17139,10 @@ bool getValuesToInterleave(Value *II,
1713817139
ValuesToInterleave.push_back(C);
1713917140
ValuesToInterleave.push_back(D);
1714017141
// intermediate II will not be needed anymore
17141-
Value *II1, *II2;
17142-
assert(match(II, m_Interleave2(m_Value(II1), m_Value(II2))) &&
17143-
"II tree is expected");
17144-
DeadInsts.push_back(cast<Instruction>(II1));
17145-
DeadInsts.push_back(cast<Instruction>(II2));
17142+
InterleaveDeadInsts.push_back(
17143+
cast<Instruction>(cast<Instruction>(II)->getOperand(0)));
17144+
InterleaveDeadInsts.push_back(
17145+
cast<Instruction>(cast<Instruction>(II)->getOperand(1)));
1714617146
return true;
1714717147
}
1714817148

@@ -17164,7 +17164,8 @@ bool AArch64TargetLowering::lowerInterleaveIntrinsicToStore(
1716417164
return false;
1716517165

1716617166
SmallVector<Value *, 4> ValuesToInterleave;
17167-
if (!getValuesToInterleave(II, ValuesToInterleave, DeadInsts)) {
17167+
SmallVector<Instruction *, 4> InterleaveDeadInsts;
17168+
if (!getValuesToInterleave(II, ValuesToInterleave, InterleaveDeadInsts)) {
1716817169
LLVM_DEBUG(dbgs() << "Matching st2 and st4 patterns failed\n");
1716917170
return false;
1717017171
}
@@ -17175,17 +17176,13 @@ bool AArch64TargetLowering::lowerInterleaveIntrinsicToStore(
1717517176
const DataLayout &DL = II->getModule()->getDataLayout();
1717617177

1717717178
bool UseScalable;
17178-
if (!isLegalInterleavedAccessType(VTy, DL, UseScalable)) {
17179-
DeadInsts.clear();
17179+
if (!isLegalInterleavedAccessType(VTy, DL, UseScalable))
1718017180
return false;
17181-
}
1718217181

1718317182
// TODO: Add support for using SVE instructions with fixed types later, using
1718417183
// the code from lowerInterleavedStore to obtain the correct container type.
17185-
if (UseScalable && !VTy->isScalableTy()) {
17186-
DeadInsts.clear();
17184+
if (UseScalable && !VTy->isScalableTy())
1718717185
return false;
17188-
}
1718917186

1719017187
unsigned NumStores = getNumInterleavedAccesses(VTy, DL, UseScalable);
1719117188

@@ -17226,7 +17223,8 @@ bool AArch64TargetLowering::lowerInterleaveIntrinsicToStore(
1722617223
}
1722717224
Builder.CreateCall(StNFunc, ValuesToInterleave);
1722817225
}
17229-
17226+
DeadInsts.insert(DeadInsts.end(), InterleaveDeadInsts.begin(),
17227+
InterleaveDeadInsts.end());
1723017228
return true;
1723117229
}
1723217230

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21828,7 +21828,7 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(
2182821828

2182921829
bool RISCVTargetLowering::lowerInterleaveIntrinsicToStore(
2183021830
IntrinsicInst *II, StoreInst *SI,
21831-
SmallVectorImpl<Instruction *> &DeadInstructions) const {
21831+
SmallVectorImpl<Instruction *> &DeadInsts) const {
2183221832
assert(SI->isSimple());
2183321833
IRBuilder<> Builder(SI);
2183421834

0 commit comments

Comments
 (0)