[llvm] [SelectionDAG] Add SDNode::user_begin() and use it in some places (PR #120509)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 20:19:53 PST 2024


================
@@ -10906,15 +10906,15 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
   // which we plan to do. This workaround can be removed once the DAG is
   // processed in topological order.
   if (N->hasOneUse()) {
-    SDNode *Use = *N->use_begin();
+    SDNode *User = *N->user_begin();
 
     // Look pass the truncate.
-    if (Use->getOpcode() == ISD::TRUNCATE && Use->hasOneUse())
-      Use = *Use->use_begin();
+    if (User->getOpcode() == ISD::TRUNCATE && User->hasOneUse())
+      User = *User->user_begin();
----------------
topperc wrote:

hasOneUser in IR returns whether or not the User of all Uses is unique. Should your proposed getOneUser() return the unique User or all Uses? Or should it only return the User if there is exactly one Use? Most of these places probably expect the latter.

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


More information about the llvm-commits mailing list