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

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 10:11:51 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/122147.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp (+1-2) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9f57884eae04df..5099833ce86cbf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -2986,8 +2986,7 @@ bool TargetLowering::SimplifyDemandedBits(
       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))) {
+    for (SDValue Op : N->ops()) {
       if (auto *C = dyn_cast<ConstantSDNode>(Op))
         if (C->isOpaque())
           return false;

``````````

</details>


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


More information about the llvm-commits mailing list