[llvm] cedeef6 - [LSR] Replace casts with an equivalent std::as_const (NFC) (#138980)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 8 03:36:40 PDT 2025


Author: Sergei Barannikov
Date: 2025-05-08T13:36:37+03:00
New Revision: cedeef6707fc702ed4ba197b3c841edbc688c78e

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

LOG: [LSR] Replace casts with an equivalent std::as_const (NFC) (#138980)

The casts / `std::as_const` are used here to select `const` overload of
`begin()`/`end()` so that the type of the returned iterator matches the
type of `J`, which is `const_iterator`.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 04719fb70552b..464e6e3b2ab97 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3946,10 +3946,8 @@ void LSRInstance::GenerateReassociationsImpl(LSRUse &LU, unsigned LUIdx,
       continue;
 
     // Collect all operands except *J.
-    SmallVector<const SCEV *, 8> InnerAddOps(
-        ((const SmallVector<const SCEV *, 8> &)AddOps).begin(), J);
-    InnerAddOps.append(std::next(J),
-                       ((const SmallVector<const SCEV *, 8> &)AddOps).end());
+    SmallVector<const SCEV *, 8> InnerAddOps(std::as_const(AddOps).begin(), J);
+    InnerAddOps.append(std::next(J), std::as_const(AddOps).end());
 
     // Don't leave just a constant behind in a register if the constant could
     // be folded into an immediate field.


        


More information about the llvm-commits mailing list