[llvm] 89e919f - Fix warnings while compiling SLPVectorizer.cpp (#118051)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 05:11:42 PST 2024


Author: Anutosh Bhat
Date: 2024-12-06T08:11:39-05:00
New Revision: 89e919fb0df391da42dbfd48cd8de268335fe672

URL: https://github.com/llvm/llvm-project/commit/89e919fb0df391da42dbfd48cd8de268335fe672
DIFF: https://github.com/llvm/llvm-project/commit/89e919fb0df391da42dbfd48cd8de268335fe672.diff

LOG: Fix warnings while compiling SLPVectorizer.cpp (#118051)

Towards #118048

I was building llvm (clang and lld) for webassembly and came across
these warnings. Not sure if they are seen in our builds too.
```
/Users/anutosh491/work/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6924:67: warning: comparison of integers of different signs: 'typename iterator_traits<user_iterator_impl<User>>::difference_type' (aka 'long') and 'unsigned int' [-Wsign-compare]
 6924 |               if (std::distance(LI->user_begin(), LI->user_end()) !=
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
 6925 |                       LI->getNumUses())
      |                       ~~~~~~~~~~~~~~~~
[ 79%] Building CXX object lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
/Users/anutosh491/work/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:9754:43: warning: comparison of integers of different signs: 'typename iterator_traits<Value *const *>::difference_type' (aka 'long') and 'unsigned int' [-Wsign-compare]
 9754 |               count(Slice, Slice.front()) ==
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
 9755 |                   (isa<UndefValue>(Slice.front()) ? VF - 1 : 1)) {
 ```


This PR tries to address those warnings.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 7ea039e04ca728..eb7ab924200699 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6922,8 +6922,8 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
               // 2. All users are deleted.
               // 3. The load broadcasts are not allowed or the load is not
               // broadcasted.
-              if (std::distance(LI->user_begin(), LI->user_end()) !=
-                      LI->getNumUses())
+              if (static_cast<unsigned int>(std::distance(
+                      LI->user_begin(), LI->user_end())) != LI->getNumUses())
                 return false;
               if (!IsLegalBroadcastLoad)
                 continue;
@@ -9716,7 +9716,8 @@ void BoUpSLP::transformNodes() {
                                              Slice.front()->getType(), 2 * VF)),
                                          1U, 2 * VF)) ||
               count(Slice, Slice.front()) ==
-                  (isa<UndefValue>(Slice.front()) ? VF - 1 : 1)) {
+                  static_cast<long>(isa<UndefValue>(Slice.front()) ? VF - 1
+                                                                   : 1)) {
             if (IsSplat)
               continue;
             InstructionsState S = getSameOpcode(Slice, *TLI);


        


More information about the llvm-commits mailing list