Skip to content

Commit 82ff301

Browse files
committed
Handling the case when ExtElt is not the OneUse
1 parent 2eea29d commit 82ff301

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,10 +2684,10 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
26842684
bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
26852685
Value *DstVec, *SrcVec;
26862686
uint64_t ExtIdx, InsIdx;
2687-
if (!match(&I, m_InsertElt(m_Value(DstVec),
2688-
m_OneUse(m_ExtractElt(m_Value(SrcVec),
2689-
m_ConstantInt(ExtIdx))),
2690-
m_ConstantInt(InsIdx))))
2687+
if (!match(&I,
2688+
m_InsertElt(m_Value(DstVec),
2689+
m_ExtractElt(m_Value(SrcVec), m_ConstantInt(ExtIdx)),
2690+
m_ConstantInt(InsIdx))))
26912691
return false;
26922692

26932693
auto *VecTy = dyn_cast<FixedVectorType>(I.getType());
@@ -2712,6 +2712,8 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
27122712

27132713
InstructionCost NewCost =
27142714
TTI.getShuffleCost(TargetTransformInfo::SK_PermuteTwoSrc, VecTy, Mask);
2715+
if (!Ext->hasOneUse())
2716+
NewCost += TTI.getVectorInstrCost(*Ext, VecTy, CostKind, ExtIdx);
27152717

27162718
if (OldCost < NewCost)
27172719
return false;

0 commit comments

Comments
 (0)