[llvm] e2449f1 - [SelectionDAG] Use SDNode::op_iterator instead of SDNodeIterator. NFC (#122147)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 09:09:59 PST 2025


Author: Craig Topper
Date: 2025-01-09T09:09:55-08:00
New Revision: e2449f1bceeefd4a603cae024a7a1db763df6834

URL: https://github.com/llvm/llvm-project/commit/e2449f1bceeefd4a603cae024a7a1db763df6834
DIFF: https://github.com/llvm/llvm-project/commit/e2449f1bceeefd4a603cae024a7a1db763df6834.diff

LOG: [SelectionDAG] Use SDNode::op_iterator instead of SDNodeIterator. NFC (#122147)

I think SDNodeIterator primarily exists because GraphTraits requires an
iterator that dereferences to SDNode*. op_iterator dereferences to
SDUse* which is implicitly convertible to SDValue.

This piece of code can use SDValue instead of SDNode* so we should
prefer to use the the more common op_iterator.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9f57884eae04df..56194e2614af2d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2985,13 +2985,11 @@ bool TargetLowering::SimplifyDemandedBits(
   if (!isTargetCanonicalConstantNode(Op) &&
       DemandedBits.isSubsetOf(Known.Zero | Known.One)) {
     // Avoid folding to a constant if any OpaqueConstant is involved.
-    const SDNode *N = Op.getNode();
-    for (SDNode *Op :
-         llvm::make_range(SDNodeIterator::begin(N), SDNodeIterator::end(N))) {
-      if (auto *C = dyn_cast<ConstantSDNode>(Op))
-        if (C->isOpaque())
-          return false;
-    }
+    if (llvm::any_of(Op->ops(), [](SDValue V) {
+          auto *C = dyn_cast<ConstantSDNode>(V);
+          return C && C->isOpaque();
+        }))
+      return false;
     if (VT.isInteger())
       return TLO.CombineTo(Op, TLO.DAG.getConstant(Known.One, dl, VT));
     if (VT.isFloatingPoint())


        


More information about the llvm-commits mailing list