[llvm] [VectorCombine] New folding pattern for extract/binop/shuffle chains (PR #145232)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 5 00:04:27 PDT 2025
================
@@ -2988,6 +2989,241 @@ bool VectorCombine::foldShuffleFromReductions(Instruction &I) {
return foldSelectShuffle(*Shuffle, true);
}
+bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
+ auto *EEI = dyn_cast<ExtractElementInst>(&I);
+ if (!EEI)
+ return false;
+
+ std::queue<Value *> InstWorklist;
+ InstructionCost OrigCost = 0;
+
+ Value *InitEEV = nullptr;
+
+ unsigned int CommonCallOp = 0;
+ Instruction::BinaryOps CommonBinOp = Instruction::BinaryOpsEnd;
+
+ bool IsFirstCallOrBinInst = true;
+ bool ShouldBeCallOrBinInst = true;
+
+ SmallVector<Value *, 3> PrevVecV(3, nullptr);
----------------
dtcxzyw wrote:
I cannot understand what this array is used for. You always access its elements with constant indices, so these elements seem to have different meanings. Can you add some comments to explain the meaning of each element?
https://github.com/llvm/llvm-project/pull/145232
More information about the llvm-commits
mailing list