[llvm] [SelectionDAG] Split sd_use_iterator into sd_user_iterator and sd_use_iterator. (PR #120531)

Sergey Barannikov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 04:02:34 PST 2024


================
@@ -13780,11 +13777,10 @@ SDValue DAGCombiner::foldSextSetcc(SDNode *N) {
 
         // Non-chain users of this value must either be the setcc in this
         // sequence or extends that can be folded into the new {z/s}ext-load.
-        for (SDNode::use_iterator UI = V->use_begin(), UE = V->use_end();
-             UI != UE; ++UI) {
+        for (SDUse &Use : V->uses()) {
----------------
s-barannikov wrote:

It would be great if `SDUse` was hidden from users (=callers) and `use_iterator::operator*` returned a pair of `SDNode*` and `unsigned` instead (possibly wrapped in another struct). It looks like `Next` and `Prev` members are implementation detail that shouldn't be exposed. Also, they increase the size of `SDUse` that makes us use `&` in range-based for loops.
We could use structured bindings with the returned pair to further simplify the loops.
(We may still be able to use structured bindings if SDUse supports std::get<>).


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


More information about the llvm-commits mailing list