This repository was archived by the owner on Sep 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -9924,11 +9924,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
99249924 VPValue *Cmp = Select->getOperand (0 );
99259925 // If the compare is checking the reduction PHI node, adjust it to check
99269926 // 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 ());
99329929 Builder.setInsertPoint (Select);
99339930
99349931 // 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(
14141414 }
14151415}
14161416
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+
14171424#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
14181425void VPValue::printAsOperand (raw_ostream &OS, VPSlotTracker &Tracker) const {
14191426 OS << Tracker.getOrCreateName (this );
Original file line number Diff line number Diff line change @@ -246,6 +246,9 @@ class VPUser {
246246 New->addUser (*this );
247247 }
248248
249+ // / Replaces all uses of \p From in the VPUser with \p To.
250+ void replaceUsesOfWith (VPValue *From, VPValue *To);
251+
249252 typedef SmallVectorImpl<VPValue *>::iterator operand_iterator;
250253 typedef SmallVectorImpl<VPValue *>::const_iterator const_operand_iterator;
251254 typedef iterator_range<operand_iterator> operand_range;
You can’t perform that action at this time.
0 commit comments