@@ -6916,15 +6916,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6916
6916
std::nullopt, CurrentOrder);
6917
6917
LLVM_DEBUG(dbgs() << "SLP: added inserts bundle.\n");
6918
6918
6919
- constexpr int NumOps = 2;
6920
- ValueList VectorOperands[NumOps];
6921
- for (int I = 0; I < NumOps; ++I) {
6922
- for (Value *V : VL)
6923
- VectorOperands[I].push_back(cast<Instruction>(V)->getOperand(I));
6924
-
6925
- TE->setOperand(I, VectorOperands[I]);
6926
- }
6927
- buildTree_rec(VectorOperands[NumOps - 1], Depth + 1, {TE, NumOps - 1});
6919
+ TE->setOperandsInOrder();
6920
+ buildTree_rec(TE->getOperand(1), Depth + 1, {TE, 1});
6928
6921
return;
6929
6922
}
6930
6923
case Instruction::Load: {
@@ -7024,14 +7017,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
7024
7017
LLVM_DEBUG(dbgs() << "SLP: added a vector of casts.\n");
7025
7018
7026
7019
TE->setOperandsInOrder();
7027
- for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
7028
- ValueList Operands;
7029
- // Prepare the operand vector.
7030
- for (Value *V : VL)
7031
- Operands.push_back(cast<Instruction>(V)->getOperand(I));
7032
-
7033
- buildTree_rec(Operands, Depth + 1, {TE, I});
7034
- }
7020
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands()))
7021
+ buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I});
7035
7022
return;
7036
7023
}
7037
7024
case Instruction::ICmp:
@@ -7116,14 +7103,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
7116
7103
}
7117
7104
7118
7105
TE->setOperandsInOrder();
7119
- for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
7120
- ValueList Operands;
7121
- // Prepare the operand vector.
7122
- for (Value *V : VL)
7123
- Operands.push_back(cast<Instruction>(V)->getOperand(I));
7124
-
7125
- buildTree_rec(Operands, Depth + 1, {TE, I});
7126
- }
7106
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands()))
7107
+ buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I});
7127
7108
return;
7128
7109
}
7129
7110
case Instruction::GetElementPtr: {
@@ -7182,30 +7163,17 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
7182
7163
return;
7183
7164
}
7184
7165
case Instruction::Store: {
7185
- // Check if the stores are consecutive or if we need to swizzle them.
7186
- ValueList Operands(VL.size());
7187
- auto *OIter = Operands.begin();
7188
- for (Value *V : VL) {
7189
- auto *SI = cast<StoreInst>(V);
7190
- *OIter = SI->getValueOperand();
7191
- ++OIter;
7192
- }
7193
- // Check that the sorted pointer operands are consecutive.
7194
- if (CurrentOrder.empty()) {
7195
- // Original stores are consecutive and does not require reordering.
7196
- TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
7197
- ReuseShuffleIndices);
7198
- TE->setOperandsInOrder();
7199
- buildTree_rec(Operands, Depth + 1, {TE, 0});
7200
- LLVM_DEBUG(dbgs() << "SLP: added a vector of stores.\n");
7201
- } else {
7166
+ bool Consecutive = CurrentOrder.empty();
7167
+ if (!Consecutive)
7202
7168
fixupOrderingIndices(CurrentOrder);
7203
- TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
7204
- ReuseShuffleIndices, CurrentOrder);
7205
- TE->setOperandsInOrder();
7206
- buildTree_rec(Operands, Depth + 1, {TE, 0});
7169
+ TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
7170
+ ReuseShuffleIndices, CurrentOrder);
7171
+ TE->setOperandsInOrder();
7172
+ buildTree_rec(TE->getOperand(0), Depth + 1, {TE, 0});
7173
+ if (Consecutive)
7174
+ LLVM_DEBUG(dbgs() << "SLP: added a vector of stores.\n");
7175
+ else
7207
7176
LLVM_DEBUG(dbgs() << "SLP: added a vector of jumbled stores.\n");
7208
- }
7209
7177
return;
7210
7178
}
7211
7179
case Instruction::Call: {
@@ -7305,14 +7273,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
7305
7273
}
7306
7274
7307
7275
TE->setOperandsInOrder();
7308
- for (unsigned I : seq<unsigned>(0, VL0->getNumOperands())) {
7309
- ValueList Operands;
7310
- // Prepare the operand vector.
7311
- for (Value *V : VL)
7312
- Operands.push_back(cast<Instruction>(V)->getOperand(I));
7313
-
7314
- buildTree_rec(Operands, Depth + 1, {TE, I});
7315
- }
7276
+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands()))
7277
+ buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I});
7316
7278
return;
7317
7279
}
7318
7280
default:
0 commit comments