Skip to content

Commit cedeef6

Browse files
authored
[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`.
1 parent 356bd2c commit cedeef6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -3946,10 +3946,8 @@ void LSRInstance::GenerateReassociationsImpl(LSRUse &LU, unsigned LUIdx,
39463946
continue;
39473947

39483948
// Collect all operands except *J.
3949-
SmallVector<const SCEV *, 8> InnerAddOps(
3950-
((const SmallVector<const SCEV *, 8> &)AddOps).begin(), J);
3951-
InnerAddOps.append(std::next(J),
3952-
((const SmallVector<const SCEV *, 8> &)AddOps).end());
3949+
SmallVector<const SCEV *, 8> InnerAddOps(std::as_const(AddOps).begin(), J);
3950+
InnerAddOps.append(std::next(J), std::as_const(AddOps).end());
39533951

39543952
// Don't leave just a constant behind in a register if the constant could
39553953
// be folded into an immediate field.

0 commit comments

Comments
 (0)