[llvm] [llvm][HashRecognize] Fix compiler warning on Arm 32-bit (PR #161821)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 3 03:44:27 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: David Spickett (DavidSpickett)

<details>
<summary>Changes</summary>

```
/home/david.spickett/llvm-project/llvm/lib/Analysis/HashRecognize.cpp:100:54: warning: comparison of integers of different signs:
'typename iterator_traits<ilist_iterator_w_bits<node_options<Instruction, true, false, void, true, BasicBlock>, false, false>>::difference_type' (aka 'int') and 'size_type' (aka 'unsigned int') [-Wsign-compare]
  100 |   return std::distance(Latch->begin(), Latch->end()) != Visited.size();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
```

With a static cast to size_t.

I thought about using Latch->size() but this skips a call to `It.setHeadBit(true);` and I'm not sure whether that would make a difference in this context.

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


1 Files Affected:

- (modified) llvm/lib/Analysis/HashRecognize.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index 5d7ee1fe8eb12..613199a5d9f7b 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -97,7 +97,8 @@ static bool containsUnreachable(const Loop &L,
       }
     }
   }
-  return std::distance(Latch->begin(), Latch->end()) != Visited.size();
+  return static_cast<size_t>(std::distance(Latch->begin(), Latch->end())) !=
+         Visited.size();
 }
 
 /// A structure that can hold either a Simple Recurrence or a Conditional

``````````

</details>


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


More information about the llvm-commits mailing list