[llvm] [VectorCombine] Combine BinOp with extract/insert to vector BinOp (PR #115213)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 02:59:04 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());
----------------
RKSimon wrote:
```
auto *VecTy = dyn_cast<FixedVectorType>(I.getType());
if (!VecTy || BO->getType() != VecTy)
return false;
```
https://github.com/llvm/llvm-project/pull/115213
More information about the llvm-commits
mailing list