[llvm] [SLP][NFCI] Don't trim indexes, reuse a variable (PR #149074)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 03:53:24 PDT 2025


https://github.com/pfusik created https://github.com/llvm/llvm-project/pull/149074

None

>From 0a0a5d7b31e4e48597f9afeecedda7648e04e98c Mon Sep 17 00:00:00 2001
From: Piotr Fusik <p.fusik at samsung.com>
Date: Wed, 16 Jul 2025 12:51:42 +0200
Subject: [PATCH] [SLP][NFCI] Don't trim indexes, reuse a variable

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 87de28044b2ae..2fef146f6fe8c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -8623,11 +8623,10 @@ void BoUpSLP::tryToVectorizeGatheredLoads(
                                State == LoadsState::CompressVectorize)
                              return false;
                            ConsecutiveNodesSize += VL.size();
-                           unsigned Start = std::distance(Slice.begin(), It);
-                           unsigned Sz = Slice.size() - Start;
+                           size_t Start = std::distance(Slice.begin(), It);
+                           size_t Sz = Slice.size() - Start;
                            return Sz < VL.size() ||
-                                  Slice.slice(std::distance(Slice.begin(), It),
-                                              VL.size()) != VL;
+                                  Slice.slice(Start, VL.size()) != VL;
                          }))
                 continue;
               // Try to build long masked gather loads.



More information about the llvm-commits mailing list