File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -1136,29 +1136,18 @@ void VPlanIngredient::print(raw_ostream &O) const {
1136
1136
template void DomTreeBuilder::Calculate<VPDominatorTree>(VPDominatorTree &DT);
1137
1137
1138
1138
void VPValue::replaceAllUsesWith (VPValue *New) {
1139
- if (this == New)
1140
- return ;
1141
- for (unsigned J = 0 ; J < getNumUsers ();) {
1142
- VPUser *User = Users[J];
1143
- bool RemovedUser = false ;
1144
- for (unsigned I = 0 , E = User->getNumOperands (); I < E; ++I)
1145
- if (User->getOperand (I) == this ) {
1146
- User->setOperand (I, New);
1147
- RemovedUser = true ;
1148
- }
1149
- // If a user got removed after updating the current user, the next user to
1150
- // update will be moved to the current position, so we only need to
1151
- // increment the index if the number of users did not change.
1152
- if (!RemovedUser)
1153
- J++;
1154
- }
1139
+ replaceUsesWithIf (New, [](VPUser &, unsigned ) { return true ; });
1155
1140
}
1156
1141
1157
1142
void VPValue::replaceUsesWithIf (
1158
1143
VPValue *New,
1159
1144
llvm::function_ref<bool (VPUser &U, unsigned Idx)> ShouldReplace) {
1145
+ // Note that this early exit is required for correctness; the implementation
1146
+ // below relies on the number of users for this VPValue to decrease, which
1147
+ // isn't the case if this == New.
1160
1148
if (this == New)
1161
1149
return ;
1150
+
1162
1151
for (unsigned J = 0 ; J < getNumUsers ();) {
1163
1152
VPUser *User = Users[J];
1164
1153
bool RemovedUser = false ;
You can’t perform that action at this time.
0 commit comments