@@ -2575,18 +2575,18 @@ class BoUpSLP {
25752575 }
25762576
25772577 /// Go through the instructions in VL and append their operands.
2578- void appendOperandsOfVL(ArrayRef<Value *> VL, Instruction *VL0) {
2578+ void appendOperandsOfVL(ArrayRef<Value *> VL, Instruction *MainOp,
2579+ Instruction *AltOp) {
25792580 assert(!VL.empty() && "Bad VL");
25802581 assert((empty() || VL.size() == getNumLanes()) &&
25812582 "Expected same number of lanes");
25822583 // IntrinsicInst::isCommutative returns true if swapping the first "two"
25832584 // arguments to the intrinsic produces the same result.
25842585 constexpr unsigned IntrinsicNumOperands = 2;
2585- unsigned NumOperands = VL0 ->getNumOperands();
2586- ArgSize = isa<IntrinsicInst>(VL0 ) ? IntrinsicNumOperands : NumOperands;
2586+ unsigned NumOperands = MainOp ->getNumOperands();
2587+ ArgSize = isa<IntrinsicInst>(MainOp ) ? IntrinsicNumOperands : NumOperands;
25872588 OpsVec.resize(NumOperands);
25882589 unsigned NumLanes = VL.size();
2589- InstructionsState S = getSameOpcode(VL, TLI);
25902590 for (unsigned OpIdx : seq<unsigned>(NumOperands))
25912591 OpsVec[OpIdx].resize(NumLanes);
25922592 for (auto [Lane, V] : enumerate(VL)) {
@@ -2595,12 +2595,12 @@ class BoUpSLP {
25952595 if (isa<PoisonValue>(V)) {
25962596 for (unsigned OpIdx : seq<unsigned>(NumOperands))
25972597 OpsVec[OpIdx][Lane] = {
2598- PoisonValue::get(VL0 ->getOperand(OpIdx)->getType()), true,
2598+ PoisonValue::get(MainOp ->getOperand(OpIdx)->getType()), true,
25992599 false};
26002600 continue;
26012601 }
2602- auto [SelectedOp, Ops] = getInterchangeableInstruction(
2603- cast<Instruction>(V), S.getMainOp(), S.getAltOp() );
2602+ auto [SelectedOp, Ops] =
2603+ getInterchangeableInstruction( cast<Instruction>(V), MainOp, AltOp );
26042604 // Our tree has just 3 nodes: the root and two operands.
26052605 // It is therefore trivial to get the APO. We only need to check the
26062606 // opcode of V and whether the operand at OpIdx is the LHS or RHS
@@ -2721,11 +2721,12 @@ class BoUpSLP {
27212721
27222722 public:
27232723 /// Initialize with all the operands of the instruction vector \p RootVL.
2724- VLOperands(ArrayRef<Value *> RootVL, Instruction *VL0, const BoUpSLP &R)
2724+ VLOperands(ArrayRef<Value *> RootVL, Instruction *MainOp,
2725+ Instruction *AltOp, const BoUpSLP &R)
27252726 : TLI(*R.TLI), DL(*R.DL), SE(*R.SE), R(R),
2726- L(R.LI->getLoopFor((VL0 ->getParent() ))) {
2727+ L(R.LI->getLoopFor(MainOp ->getParent())) {
27272728 // Append all the operands of RootVL.
2728- appendOperandsOfVL(RootVL, VL0 );
2729+ appendOperandsOfVL(RootVL, MainOp, AltOp );
27292730 }
27302731
27312732 /// \Returns a value vector with the operands across all lanes for the
@@ -3517,7 +3518,7 @@ class BoUpSLP {
35173518
35183519 /// Set this bundle's operand from Scalars.
35193520 void setOperand(const BoUpSLP &R, bool RequireReorder = false) {
3520- VLOperands Ops(Scalars, MainOp, R);
3521+ VLOperands Ops(Scalars, MainOp, AltOp, R);
35213522 if (RequireReorder)
35223523 Ops.reorder();
35233524 for (unsigned I : seq<unsigned>(MainOp->getNumOperands()))
@@ -8733,7 +8734,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
87338734 LLVM_DEBUG(dbgs() << "SLP: added a vector of compares.\n");
87348735
87358736 ValueList Left, Right;
8736- VLOperands Ops(VL, VL0, *this);
8737+ VLOperands Ops(VL, VL0, S.getAltOp(), *this);
87378738 if (cast<CmpInst>(VL0)->isCommutative()) {
87388739 // Commutative predicate - collect + sort operands of the instructions
87398740 // so that each side is more likely to have the same opcode.
0 commit comments