[llvm] [SLP]Reduce number of alternate instruction, where possible (PR #123360)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 03:52:33 PST 2025
================
@@ -8327,6 +8597,48 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
S.getMainOp()) &&
!all_of(VL, isVectorLikeInstWithConstOps)) ||
NotProfitableForVectorization(VL)) {
+ if (!S) {
+ Instruction *MainOp = nullptr;
+ Instruction *AltOp = nullptr;
+ for (Value *V : VL) {
+ if (isa<PoisonValue>(V))
+ continue;
+ auto *I = dyn_cast<Instruction>(V);
+ if (!I) {
+ MainOp = AltOp = nullptr;
+ break;
+ }
+ if (!MainOp) {
+ MainOp = I;
+ continue;
+ }
+ if (MainOp->getOpcode() == I->getOpcode()) {
+ if (I->getParent() != MainOp->getParent()) {
+ MainOp = AltOp = nullptr;
+ break;
+ }
+ continue;
+ }
+ if (!AltOp) {
+ AltOp = I;
+ continue;
+ }
+ if (AltOp->getOpcode() == I->getOpcode()) {
+ if (I->getParent() != AltOp->getParent()) {
+ MainOp = AltOp = nullptr;
+ break;
+ }
+ continue;
+ }
+ MainOp = AltOp = nullptr;
+ break;
+ }
+ // Last chance to try to vectorize alternate node.
+ constexpr unsigned SmallNodeSize = 4;
----------------
RKSimon wrote:
Pull out these duplicate thresholds?
https://github.com/llvm/llvm-project/pull/123360
More information about the llvm-commits
mailing list