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

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


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/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.

>From 23ca7cff12a3793ff8b75193bffbfa023498f2f3 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Wed, 8 Jan 2025 10:07:44 -0800
Subject: [PATCH] [SelectionDAG] Use SDNode::op_iterator instead of
 SDNodeIterator. NFC

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.
---
 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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;



More information about the llvm-commits mailing list