[llvm] r280430 - [SelectionDAGBuilder] Add const to relevant places
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 1 16:35:27 PDT 2016
Author: hiraditya
Date: Thu Sep 1 18:35:26 2016
New Revision: 280430
URL: http://llvm.org/viewvc/llvm-project?rev=280430&view=rev
Log:
[SelectionDAGBuilder] Add const to relevant places
Reviewers: hans, evandro, sebpop
Differential Revision: https://reviews.llvm.org/D24112
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=280430&r1=280429&r2=280430&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Thu Sep 1 18:35:26 2016
@@ -8327,14 +8327,14 @@ void SelectionDAGBuilder::updateDAGForMa
}
bool SelectionDAGBuilder::isDense(const CaseClusterVector &Clusters,
- unsigned *TotalCases, unsigned First,
- unsigned Last,
- unsigned Density) {
+ const SmallVectorImpl<unsigned> &TotalCases,
+ unsigned First, unsigned Last,
+ unsigned Density) const {
assert(Last >= First);
assert(TotalCases[Last] >= TotalCases[First]);
- APInt LowCase = Clusters[First].Low->getValue();
- APInt HighCase = Clusters[Last].High->getValue();
+ const APInt &LowCase = Clusters[First].Low->getValue();
+ const APInt &HighCase = Clusters[Last].High->getValue();
assert(LowCase.getBitWidth() == HighCase.getBitWidth());
// FIXME: A range of consecutive cases has 100% density, but only requires one
@@ -8363,7 +8363,7 @@ static inline bool areJTsAllowed(const T
TLI.isOperationLegalOrCustom(ISD::BRIND, MVT::Other);
}
-bool SelectionDAGBuilder::buildJumpTable(CaseClusterVector &Clusters,
+bool SelectionDAGBuilder::buildJumpTable(const CaseClusterVector &Clusters,
unsigned First, unsigned Last,
const SwitchInst *SI,
MachineBasicBlock *DefaultMBB,
@@ -8382,12 +8382,12 @@ bool SelectionDAGBuilder::buildJumpTable
for (unsigned I = First; I <= Last; ++I) {
assert(Clusters[I].Kind == CC_Range);
Prob += Clusters[I].Prob;
- APInt Low = Clusters[I].Low->getValue();
- APInt High = Clusters[I].High->getValue();
+ const APInt &Low = Clusters[I].Low->getValue();
+ const APInt &High = Clusters[I].High->getValue();
NumCmps += (Low == High) ? 1 : 2;
if (I != First) {
// Fill the gap between this and the previous cluster.
- APInt PreviousHigh = Clusters[I - 1].High->getValue();
+ const APInt &PreviousHigh = Clusters[I - 1].High->getValue();
assert(PreviousHigh.slt(Low));
uint64_t Gap = (Low - PreviousHigh).getLimitedValue() - 1;
for (uint64_t J = 0; J < Gap; J++)
@@ -8462,8 +8462,8 @@ void SelectionDAGBuilder::findJumpTables
SmallVector<unsigned, 8> TotalCases(N);
for (unsigned i = 0; i < N; ++i) {
- APInt Hi = Clusters[i].High->getValue();
- APInt Lo = Clusters[i].Low->getValue();
+ const APInt &Hi = Clusters[i].High->getValue();
+ const APInt &Lo = Clusters[i].Low->getValue();
TotalCases[i] = (Hi - Lo).getLimitedValue() + 1;
if (i != 0)
TotalCases[i] += TotalCases[i - 1];
@@ -8473,7 +8473,7 @@ void SelectionDAGBuilder::findJumpTables
if (DefaultMBB->getParent()->getFunction()->optForSize())
MinDensity = OptsizeJumpTableDensity;
if (N >= MinJumpTableSize
- && isDense(Clusters, &TotalCases[0], 0, N - 1, MinDensity)) {
+ && isDense(Clusters, TotalCases, 0, N - 1, MinDensity)) {
// Cheap case: the whole range might be suitable for jump table.
CaseCluster JTCluster;
if (buildJumpTable(Clusters, 0, N - 1, SI, DefaultMBB, JTCluster)) {
@@ -8518,7 +8518,7 @@ void SelectionDAGBuilder::findJumpTables
// Search for a solution that results in fewer partitions.
for (int64_t j = N - 1; j > i; j--) {
// Try building a partition from Clusters[i..j].
- if (isDense(Clusters, &TotalCases[0], i, j, MinDensity)) {
+ if (isDense(Clusters, TotalCases, i, j, MinDensity)) {
unsigned NumPartitions = 1 + (j == N - 1 ? 0 : MinPartitions[j + 1]);
bool IsTable = j - i + 1 >= MinJumpTableSize;
unsigned Tables = IsTable + (j == N - 1 ? 0 : NumTables[j + 1]);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=280430&r1=280429&r2=280430&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Thu Sep 1 18:35:26 2016
@@ -305,12 +305,13 @@ private:
};
/// Check whether a range of clusters is dense enough for a jump table.
- bool isDense(const CaseClusterVector &Clusters, unsigned *TotalCases,
- unsigned First, unsigned Last, unsigned MinDensity);
+ bool isDense(const CaseClusterVector &Clusters,
+ const SmallVectorImpl<unsigned> &TotalCases,
+ unsigned First, unsigned Last, unsigned MinDensity) const;
/// Build a jump table cluster from Clusters[First..Last]. Returns false if it
/// decides it's not a good idea.
- bool buildJumpTable(CaseClusterVector &Clusters, unsigned First,
+ bool buildJumpTable(const CaseClusterVector &Clusters, unsigned First,
unsigned Last, const SwitchInst *SI,
MachineBasicBlock *DefaultMBB, CaseCluster &JTCluster);
More information about the llvm-commits
mailing list