@@ -2489,42 +2489,39 @@ class BoUpSLP {
24892489 ArgSize = isa<IntrinsicInst>(MainOp) ? IntrinsicNumOperands : NumOperands;
24902490 OpsVec.resize(NumOperands);
24912491 unsigned NumLanes = VL.size();
2492- for (unsigned OpIdx = 0; OpIdx != NumOperands; ++OpIdx) {
2493- OpsVec[OpIdx].resize(NumLanes);
2494- for (unsigned Lane = 0; Lane != NumLanes; ++Lane) {
2495- assert((isa<Instruction>(VL[Lane]) || isa<PoisonValue>(VL[Lane])) &&
2496- "Expected instruction or poison value");
2497- // Our tree has just 3 nodes: the root and two operands.
2498- // It is therefore trivial to get the APO. We only need to check the
2499- // opcode of VL[Lane] and whether the operand at OpIdx is the LHS or
2500- // RHS operand. The LHS operand of both add and sub is never attached
2501- // to an inversese operation in the linearized form, therefore its APO
2502- // is false. The RHS is true only if VL[Lane] is an inverse operation.
2503-
2504- // Since operand reordering is performed on groups of commutative
2505- // operations or alternating sequences (e.g., +, -), we can safely
2506- // tell the inverse operations by checking commutativity.
2507- if (isa<PoisonValue>(VL[Lane])) {
2508- if (auto *EI = dyn_cast<ExtractElementInst>(MainOp)) {
2509- if (OpIdx == 0) {
2510- OpsVec[OpIdx][Lane] = {EI->getVectorOperand(), true, false};
2511- continue;
2512- }
2513- } else if (auto *EV = dyn_cast<ExtractValueInst>(MainOp)) {
2514- if (OpIdx == 0) {
2515- OpsVec[OpIdx][Lane] = {EV->getAggregateOperand(), true, false};
2516- continue;
2517- }
2518- }
2492+ for (OperandDataVec &Ops : OpsVec)
2493+ Ops.resize(NumLanes);
2494+ for (unsigned Lane : seq<unsigned>(NumLanes)) {
2495+ Value *V = VL[Lane];
2496+ assert((isa<Instruction>(V) || isa<PoisonValue>(V)) &&
2497+ "Expected instruction or poison value");
2498+ if (isa<PoisonValue>(V)) {
2499+ for (unsigned OpIdx : seq<unsigned>(NumOperands))
25192500 OpsVec[OpIdx][Lane] = {
25202501 PoisonValue::get(MainOp->getOperand(OpIdx)->getType()), true,
25212502 false};
2522- continue;
2503+ if (auto *EI = dyn_cast<ExtractElementInst>(MainOp)) {
2504+ OpsVec[0][Lane] = {EI->getVectorOperand(), true, false};
2505+ } else if (auto *EV = dyn_cast<ExtractValueInst>(MainOp)) {
2506+ OpsVec[0][Lane] = {EV->getAggregateOperand(), true, false};
25232507 }
2524- bool IsInverseOperation = !isCommutative(cast<Instruction>(VL[Lane]));
2508+ continue;
2509+ }
2510+ // Our tree has just 3 nodes: the root and two operands.
2511+ // It is therefore trivial to get the APO. We only need to check the
2512+ // opcode of V and whether the operand at OpIdx is the LHS or RHS
2513+ // operand. The LHS operand of both add and sub is never attached to an
2514+ // inversese operation in the linearized form, therefore its APO is
2515+ // false. The RHS is true only if V is an inverse operation.
2516+
2517+ // Since operand reordering is performed on groups of commutative
2518+ // operations or alternating sequences (e.g., +, -), we can safely tell
2519+ // the inverse operations by checking commutativity.
2520+ bool IsInverseOperation = !isCommutative(cast<Instruction>(V));
2521+ for (unsigned OpIdx = 0; OpIdx != NumOperands; ++OpIdx) {
25252522 bool APO = (OpIdx == 0) ? false : IsInverseOperation;
2526- OpsVec[OpIdx][Lane] = {cast<Instruction>(VL[Lane] )->getOperand(OpIdx),
2527- APO, false};
2523+ OpsVec[OpIdx][Lane] = {cast<Instruction>(V )->getOperand(OpIdx), APO ,
2524+ false};
25282525 }
25292526 }
25302527 }
0 commit comments