[llvm] [llvm][HashRecognize] Fix compiler warning on Arm 32-bit (PR #161821)
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 3 03:43:44 PDT 2025
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/161821
```
/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.
>From 5859523e0efd901595bcc1b50e0e8dec43db52d8 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at linaro.org>
Date: Fri, 3 Oct 2025 10:40:51 +0000
Subject: [PATCH] [llvm][HashRecognize] Fix compiler warning on Arm 32-bit
/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.
---
llvm/lib/Analysis/HashRecognize.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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
More information about the llvm-commits
mailing list