[llvm] d0a6434 - [SLP] Reduce scope of variable using if clause [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 27 09:14:37 PDT 2024


Author: Philip Reames
Date: 2024-08-27T09:14:30-07:00
New Revision: d0a6434e86880f55e225ffa2e39c77f10aea1604

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

LOG: [SLP] Reduce scope of variable using if clause [NFC]

This particular variable name is shadowed by another lower in the
function, so reducing it's scope to it's single use removes the
shadowing and makes the code much less error prone.

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 4be113f07ec795..be8e2aa99d503d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -17579,14 +17579,14 @@ class HorizontalReduction {
     // If there are a sufficient number of reduction values, reduce
     // to a nearby power-of-2. We can safely generate oversized
     // vectors and rely on the backend to split them to legal sizes.
-    unsigned NumReducedVals =
-        std::accumulate(ReducedVals.begin(), ReducedVals.end(), 0,
-                        [](unsigned Num, ArrayRef<Value *> Vals) -> unsigned {
-                          if (!isGoodForReduction(Vals))
-                            return Num;
-                          return Num + Vals.size();
-                        });
-    if (NumReducedVals < ReductionLimit &&
+    if (unsigned NumReducedVals = std::accumulate(
+            ReducedVals.begin(), ReducedVals.end(), 0,
+            [](unsigned Num, ArrayRef<Value *> Vals) -> unsigned {
+              if (!isGoodForReduction(Vals))
+                return Num;
+              return Num + Vals.size();
+            });
+        NumReducedVals < ReductionLimit &&
         (!AllowHorRdxIdenityOptimization ||
          all_of(ReducedVals, [](ArrayRef<Value *> RedV) {
            return RedV.size() < 2 || !allConstant(RedV) || !isSplat(RedV);


        


More information about the llvm-commits mailing list