@@ -2575,18 +2575,18 @@ class BoUpSLP {
2575
2575
}
2576
2576
2577
2577
/// 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) {
2579
2580
assert(!VL.empty() && "Bad VL");
2580
2581
assert((empty() || VL.size() == getNumLanes()) &&
2581
2582
"Expected same number of lanes");
2582
2583
// IntrinsicInst::isCommutative returns true if swapping the first "two"
2583
2584
// arguments to the intrinsic produces the same result.
2584
2585
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;
2587
2588
OpsVec.resize(NumOperands);
2588
2589
unsigned NumLanes = VL.size();
2589
- InstructionsState S = getSameOpcode(VL, TLI);
2590
2590
for (unsigned OpIdx : seq<unsigned>(NumOperands))
2591
2591
OpsVec[OpIdx].resize(NumLanes);
2592
2592
for (auto [Lane, V] : enumerate(VL)) {
@@ -2595,12 +2595,12 @@ class BoUpSLP {
2595
2595
if (isa<PoisonValue>(V)) {
2596
2596
for (unsigned OpIdx : seq<unsigned>(NumOperands))
2597
2597
OpsVec[OpIdx][Lane] = {
2598
- PoisonValue::get(VL0 ->getOperand(OpIdx)->getType()), true,
2598
+ PoisonValue::get(MainOp ->getOperand(OpIdx)->getType()), true,
2599
2599
false};
2600
2600
continue;
2601
2601
}
2602
- auto [SelectedOp, Ops] = getInterchangeableInstruction(
2603
- cast<Instruction>(V), S.getMainOp(), S.getAltOp() );
2602
+ auto [SelectedOp, Ops] =
2603
+ getInterchangeableInstruction( cast<Instruction>(V), MainOp, AltOp );
2604
2604
// Our tree has just 3 nodes: the root and two operands.
2605
2605
// It is therefore trivial to get the APO. We only need to check the
2606
2606
// opcode of V and whether the operand at OpIdx is the LHS or RHS
@@ -2721,11 +2721,12 @@ class BoUpSLP {
2721
2721
2722
2722
public:
2723
2723
/// 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)
2725
2726
: 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())) {
2727
2728
// Append all the operands of RootVL.
2728
- appendOperandsOfVL(RootVL, VL0 );
2729
+ appendOperandsOfVL(RootVL, MainOp, AltOp );
2729
2730
}
2730
2731
2731
2732
/// \Returns a value vector with the operands across all lanes for the
@@ -3517,7 +3518,7 @@ class BoUpSLP {
3517
3518
3518
3519
/// Set this bundle's operand from Scalars.
3519
3520
void setOperand(const BoUpSLP &R, bool RequireReorder = false) {
3520
- VLOperands Ops(Scalars, MainOp, R);
3521
+ VLOperands Ops(Scalars, MainOp, AltOp, R);
3521
3522
if (RequireReorder)
3522
3523
Ops.reorder();
3523
3524
for (unsigned I : seq<unsigned>(MainOp->getNumOperands()))
@@ -8733,7 +8734,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
8733
8734
LLVM_DEBUG(dbgs() << "SLP: added a vector of compares.\n");
8734
8735
8735
8736
ValueList Left, Right;
8736
- VLOperands Ops(VL, VL0, *this);
8737
+ VLOperands Ops(VL, VL0, S.getAltOp(), *this);
8737
8738
if (cast<CmpInst>(VL0)->isCommutative()) {
8738
8739
// Commutative predicate - collect + sort operands of the instructions
8739
8740
// so that each side is more likely to have the same opcode.
0 commit comments