[llvm] [LSR] Replace casts with an equivalent std::as_const (NFC) (PR #138980)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 15:24:28 PDT 2025
https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/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`.
>From 4a7dbbb1aa033b952788546e870a38c813105bdb Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Thu, 8 May 2025 01:17:38 +0300
Subject: [PATCH] [LSR] Replace casts with an equivalent std::as_const (NFC)
---
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
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