[llvm] [X86] Fix potential CSE issues in commuteSelect multi-use path (PR #214092)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 06:11:59 PDT 2026


================
@@ -48594,11 +48594,13 @@ static SDValue commuteSelect(SDNode *N, SelectionDAG &DAG, const SDLoc &DL,
     return DAG.getSelect(DL, LHS.getValueType(), NewCond, RHS, LHS);
 
   // Invert the setcc for all users and commute all vselects.
-  DAG.ReplaceAllUsesOfValueWith(Cond, NewCond);
-  for (SDNode *User : NewCond->users()) {
+  SmallVector<SDNode *> UsersToUpdate(Cond->users());
+  for (SDNode *User : UsersToUpdate) {
----------------
phoebewang wrote:

How about use `make_early_inc_range`?

https://github.com/llvm/llvm-project/pull/214092


More information about the llvm-commits mailing list