@@ -1072,11 +1072,11 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1072
1072
if (!isTriviallyVectorizable(BaseID) && BaseMappings.empty())
1073
1073
return InstructionsState::invalid();
1074
1074
}
1075
- <<<<<<< HEAD
1075
+ bool AnyPoison = InstCnt != VL.size();
1076
1076
// Currently, this is only used for binary ops.
1077
1077
// TODO: support all instructions
1078
1078
SmallVector<InterchangeableInstruction> InterchangeableOpcode =
1079
- getInterchangeableInstruction(cast<Instruction>(VL[BaseIndex] ));
1079
+ getInterchangeableInstruction(cast<Instruction>(V ));
1080
1080
SmallVector<InterchangeableInstruction> AlternateInterchangeableOpcode;
1081
1081
auto UpdateInterchangeableOpcode =
1082
1082
[](SmallVector<InterchangeableInstruction> &LHS,
@@ -1089,9 +1089,6 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1089
1089
LHS.swap(NewInterchangeableOpcode);
1090
1090
return true;
1091
1091
};
1092
- =======
1093
- bool AnyPoison = InstCnt != VL.size();
1094
- >>>>>>> upstream/main
1095
1092
for (int Cnt = 0, E = VL.size(); Cnt < E; Cnt++) {
1096
1093
auto *I = dyn_cast<Instruction>(VL[Cnt]);
1097
1094
if (!I)
@@ -1123,7 +1120,7 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1123
1120
}),
1124
1121
ThisInterchangeableOpcode.end());
1125
1122
if (InterchangeableOpcode.empty() || ThisInterchangeableOpcode.empty())
1126
- return InstructionsState(VL[BaseIndex], nullptr, nullptr );
1123
+ return InstructionsState::invalid( );
1127
1124
AlternateInterchangeableOpcode.swap(ThisInterchangeableOpcode);
1128
1125
continue;
1129
1126
}
@@ -1230,7 +1227,6 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1230
1227
return InstructionsState::invalid();
1231
1228
}
1232
1229
1233
- <<<<<<< HEAD
1234
1230
if (IsBinOp) {
1235
1231
auto FindOp = [&](ArrayRef<InterchangeableInstruction> CandidateOp) {
1236
1232
for (Value *V : VL)
@@ -1244,12 +1240,9 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
1244
1240
Instruction *AltOp = AlternateInterchangeableOpcode.empty()
1245
1241
? MainOp
1246
1242
: FindOp(AlternateInterchangeableOpcode);
1247
- return InstructionsState(VL[BaseIndex], MainOp, AltOp);
1243
+ return InstructionsState(MainOp, AltOp);
1248
1244
}
1249
- return InstructionsState(VL[BaseIndex], cast<Instruction>(VL[BaseIndex]),
1250
- =======
1251
1245
return InstructionsState(cast<Instruction>(V),
1252
- >>>>>>> upstream/main
1253
1246
cast<Instruction>(VL[AltIndex]));
1254
1247
}
1255
1248
@@ -2593,11 +2586,18 @@ class BoUpSLP {
2593
2586
InstructionsState S = getSameOpcode(VL, TLI);
2594
2587
for (unsigned OpIdx : seq<unsigned>(NumOperands))
2595
2588
OpsVec[OpIdx].resize(NumLanes);
2596
- <<<<<<< HEAD
2597
- for (auto [I, V] : enumerate(VL)) {
2598
- assert(isa<Instruction>(V) && "Expected instruction");
2589
+ for (auto [Lane, V] : enumerate(VL)) {
2590
+ assert((isa<Instruction>(V) || isa<PoisonValue>(V)) &&
2591
+ "Expected instruction or poison value");
2592
+ if (isa<PoisonValue>(V)) {
2593
+ for (unsigned OpIdx : seq<unsigned>(NumOperands))
2594
+ OpsVec[OpIdx][Lane] = {
2595
+ PoisonValue::get(VL0->getOperand(OpIdx)->getType()), true,
2596
+ false};
2597
+ continue;
2598
+ }
2599
2599
auto [SelectedOp, Ops] = getInterchangeableInstruction(
2600
- cast<Instruction>(V), S.MainOp , S.AltOp );
2600
+ cast<Instruction>(V), S.getMainOp() , S.getAltOp() );
2601
2601
// Our tree has just 3 nodes: the root and two operands.
2602
2602
// It is therefore trivial to get the APO. We only need to check the
2603
2603
// opcode of V and whether the operand at OpIdx is the LHS or RHS
@@ -2610,30 +2610,8 @@ class BoUpSLP {
2610
2610
// tell the inverse operations by checking commutativity.
2611
2611
bool IsInverseOperation = !isCommutative(cast<Instruction>(SelectedOp));
2612
2612
for (unsigned OpIdx : seq<unsigned>(NumOperands)) {
2613
- =======
2614
- for (unsigned Lane = 0; Lane != NumLanes; ++Lane) {
2615
- assert((isa<Instruction>(VL[Lane]) || isa<PoisonValue>(VL[Lane])) &&
2616
- "Expected instruction or poison value");
2617
- // Our tree has just 3 nodes: the root and two operands.
2618
- // It is therefore trivial to get the APO. We only need to check the
2619
- // opcode of VL[Lane] and whether the operand at OpIdx is the LHS or
2620
- // RHS operand. The LHS operand of both add and sub is never attached
2621
- // to an inversese operation in the linearized form, therefore its APO
2622
- // is false. The RHS is true only if VL[Lane] is an inverse operation.
2623
-
2624
- // Since operand reordering is performed on groups of commutative
2625
- // operations or alternating sequences (e.g., +, -), we can safely
2626
- // tell the inverse operations by checking commutativity.
2627
- if (isa<PoisonValue>(VL[Lane])) {
2628
- OpsVec[OpIdx][Lane] = {
2629
- PoisonValue::get(VL0->getOperand(OpIdx)->getType()), true,
2630
- false};
2631
- continue;
2632
- }
2633
- bool IsInverseOperation = !isCommutative(cast<Instruction>(VL[Lane]));
2634
- >>>>>>> upstream/main
2635
2613
bool APO = (OpIdx == 0) ? false : IsInverseOperation;
2636
- OpsVec[OpIdx][I ] = {Ops[OpIdx], APO, false};
2614
+ OpsVec[OpIdx][Lane ] = {Ops[OpIdx], APO, false};
2637
2615
}
2638
2616
}
2639
2617
}
@@ -3534,32 +3512,13 @@ class BoUpSLP {
3534
3512
copy(OpVL, Operands[OpIdx].begin());
3535
3513
}
3536
3514
3537
- <<<<<<< HEAD
3538
- /// Set the operands of this bundle in their original order.
3539
- void setOperandsInOrder() {
3540
- assert(Operands.empty() && "Already initialized?");
3541
- auto *I0 = cast<Instruction>(Scalars[0]);
3542
- Operands.resize(I0->getNumOperands());
3543
- unsigned NumLanes = Scalars.size();
3544
- unsigned NumOperands = I0->getNumOperands();
3545
- for (unsigned OpIdx : seq<unsigned>(NumOperands))
3546
- Operands[OpIdx].resize(NumLanes);
3547
- for (auto [I, V] : enumerate(Scalars)) {
3548
- auto [SelectedOp, Ops] =
3549
- getInterchangeableInstruction(cast<Instruction>(V), MainOp, AltOp);
3550
- assert(Ops.size() == NumOperands && "Expected same number of operands");
3551
- for (auto [J, Op] : enumerate(Ops))
3552
- Operands[J][I] = Op;
3553
- }
3554
- =======
3555
3515
/// Set this bundle's operand from Scalars.
3556
3516
void setOperand(const BoUpSLP &R, bool RequireReorder = false) {
3557
3517
VLOperands Ops(Scalars, MainOp, R);
3558
3518
if (RequireReorder)
3559
3519
Ops.reorder();
3560
3520
for (unsigned I : seq<unsigned>(MainOp->getNumOperands()))
3561
3521
setOperand(I, Ops.getVL(I));
3562
- >>>>>>> upstream/main
3563
3522
}
3564
3523
3565
3524
/// Reorders operands of the node to the given mask \p Mask.
0 commit comments