[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 00:53:16 PDT 2026


================
@@ -48594,11 +48594,14 @@ 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.
+  SmallVector<SDNode *> UsersToUpdate(Cond->users());
   DAG.ReplaceAllUsesOfValueWith(Cond, NewCond);
-  for (SDNode *User : NewCond->users()) {
+  for (SDNode *User : UsersToUpdate) {
     SDValue UserLHS = User->getOperand(1);
     SDValue UserRHS = User->getOperand(2);
-    DAG.UpdateNodeOperands(User, NewCond, UserRHS, UserLHS);
+    [[maybe_unused]] SDNode *Updated =
+        DAG.UpdateNodeOperands(User, NewCond, UserRHS, UserLHS);
----------------
phoebewang wrote:

Given we update `NewCond` together, do we still need `ReplaceAllUsesOfValueWith`?

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


More information about the llvm-commits mailing list