-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[LSR] Replace casts with an equivalent std::as_const (NFC) #138980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Sergei Barannikov (s-barannikov) ChangesThe casts / Full diff: https://github.com/llvm/llvm-project/pull/138980.diff 1 Files Affected:
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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Replacing C-style casts with C++17 as_const
, already used in a few places: StaticAnalyzer, MLIR, MLIR elsewhere.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/19657 Here is the relevant piece of the build log for the reference
|
The casts /
std::as_const
are used here to selectconst
overload ofbegin()
/end()
so that the type of the returned iterator matches the type ofJ
, which isconst_iterator
.