File tree 3 files changed +12
-5
lines changed
llvm/lib/Transforms/Vectorize 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -9924,11 +9924,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
9924
9924
VPValue *Cmp = Select->getOperand(0);
9925
9925
// If the compare is checking the reduction PHI node, adjust it to check
9926
9926
// the start value.
9927
- if (VPRecipeBase *CmpR = Cmp->getDefiningRecipe()) {
9928
- for (unsigned I = 0; I != CmpR->getNumOperands(); ++I)
9929
- if (CmpR->getOperand(I) == PhiR)
9930
- CmpR->setOperand(I, PhiR->getStartValue());
9931
- }
9927
+ if (VPRecipeBase *CmpR = Cmp->getDefiningRecipe())
9928
+ CmpR->replaceUsesOfWith(PhiR, PhiR->getStartValue());
9932
9929
Builder.setInsertPoint(Select);
9933
9930
9934
9931
// If the true value of the select is the reduction phi, the new value is
Original file line number Diff line number Diff line change @@ -1414,6 +1414,13 @@ void VPValue::replaceUsesWithIf(
1414
1414
}
1415
1415
}
1416
1416
1417
+ void VPUser::replaceUsesOfWith (VPValue *From, VPValue *To) {
1418
+ for (unsigned Idx = 0 ; Idx != getNumOperands (); ++Idx) {
1419
+ if (getOperand (Idx) == From)
1420
+ setOperand (Idx, To);
1421
+ }
1422
+ }
1423
+
1417
1424
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1418
1425
void VPValue::printAsOperand (raw_ostream &OS, VPSlotTracker &Tracker) const {
1419
1426
OS << Tracker.getOrCreateName (this );
Original file line number Diff line number Diff line change @@ -246,6 +246,9 @@ class VPUser {
246
246
New->addUser (*this );
247
247
}
248
248
249
+ // / Replaces all uses of \p From in the VPUser with \p To.
250
+ void replaceUsesOfWith (VPValue *From, VPValue *To);
251
+
249
252
typedef SmallVectorImpl<VPValue *>::iterator operand_iterator;
250
253
typedef SmallVectorImpl<VPValue *>::const_iterator const_operand_iterator;
251
254
typedef iterator_range<operand_iterator> operand_range;
You can’t perform that action at this time.
0 commit comments