[llvm] [VectorCombine] Combine BinOp with extract/insert to vector BinOp (PR #115213)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 07:55:23 PST 2024
================
@@ -2678,6 +2679,52 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {
return true;
}
+/// insert (DstVec, (extract (binop), ExtIdx), InsIdx) -->
+/// shuffl (DstVec, (binop), Mask)
+bool VectorCombine::foldInsExtOfBinOpShuffle(Instruction &I) {
+ Value *DstVec;
+ BinaryOperator *BO;
+ uint64_t ExtIdx, InsIdx;
+ if (!match(&I, m_InsertElt(
+ m_Value(DstVec),
+ m_OneUse(m_ExtractElt(m_BinOp(BO), m_ConstantInt(ExtIdx))),
+ m_ConstantInt(InsIdx))))
+ return false;
+
+ if (!isSafeToSpeculativelyExecute(BO))
+ return false;
+
+ auto *VecTy = cast<FixedVectorType>(I.getType());
+ if (BO->getType() != VecTy)
+ return false;
+
+ unsigned NumElts = VecTy->getNumElements();
+ if (ExtIdx >= NumElts)
+ return false;
+
+ SmallVector<int> Mask(NumElts);
+ std::iota(Mask.begin(), Mask.end(), 0);
----------------
ParkHanbum wrote:
I see! thakns for letting me know
https://github.com/llvm/llvm-project/pull/115213
More information about the llvm-commits
mailing list