Skip to content

Commit 791d267

Browse files
committed
More const's and a debug run line
1 parent eab7f12 commit 791d267

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/lib/CodeGen/SelectOptimize.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class SelectOptimizeImpl {
128128
/// act like selects. For example Or(Zext(icmp), X) can be treated like
129129
/// select(icmp, X|1, X).
130130
class SelectLike {
131-
private:
132131
SelectLike(Instruction *I) : I(I) {}
133132

134133
Instruction *I;
@@ -305,7 +304,7 @@ class SelectOptimizeImpl {
305304
Instruction *SI, bool ForSinking = false);
306305

307306
// Returns true if the condition of the select is highly predictable.
308-
bool isSelectHighlyPredictable(SelectLike SI);
307+
bool isSelectHighlyPredictable(const SelectLike SI);
309308

310309
// Loop-level checks to determine if a non-predicated version (with branches)
311310
// of the given loop is more profitable than its predicated version.
@@ -325,14 +324,14 @@ class SelectOptimizeImpl {
325324
std::optional<uint64_t> computeInstCost(const Instruction *I);
326325

327326
// Returns the misprediction cost of a given select when converted to branch.
328-
Scaled64 getMispredictionCost(SelectLike SI, const Scaled64 CondCost);
327+
Scaled64 getMispredictionCost(const SelectLike SI, const Scaled64 CondCost);
329328

330329
// Returns the cost of a branch when the prediction is correct.
331330
Scaled64 getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
332-
SelectLike SI);
331+
const SelectLike SI);
333332

334333
// Returns true if the target architecture supports lowering a given select.
335-
bool isSelectKindSupported(SelectLike SI);
334+
bool isSelectKindSupported(const SelectLike SI);
336335
};
337336

338337
class SelectOptimize : public FunctionPass {
@@ -880,7 +879,7 @@ static InstructionCost divideNearest(InstructionCost Numerator,
880879
return (Numerator + (Denominator / 2)) / Denominator;
881880
}
882881

883-
static bool extractBranchWeights(SelectOptimizeImpl::SelectLike SI,
882+
static bool extractBranchWeights(const SelectOptimizeImpl::SelectLike SI,
884883
uint64_t &TrueVal, uint64_t &FalseVal) {
885884
if (isa<SelectInst>(SI.getI()))
886885
return extractBranchWeights(*SI.getI(), TrueVal, FalseVal);
@@ -1008,7 +1007,7 @@ void SelectOptimizeImpl::getExclBackwardsSlice(Instruction *I,
10081007
}
10091008
}
10101009

1011-
bool SelectOptimizeImpl::isSelectHighlyPredictable(SelectLike SI) {
1010+
bool SelectOptimizeImpl::isSelectHighlyPredictable(const SelectLike SI) {
10121011
uint64_t TrueWeight, FalseWeight;
10131012
if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
10141013
uint64_t Max = std::max(TrueWeight, FalseWeight);
@@ -1190,7 +1189,7 @@ SelectOptimizeImpl::computeInstCost(const Instruction *I) {
11901189
}
11911190

11921191
ScaledNumber<uint64_t>
1193-
SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
1192+
SelectOptimizeImpl::getMispredictionCost(const SelectLike SI,
11941193
const Scaled64 CondCost) {
11951194
uint64_t MispredictPenalty = TSchedModel.getMCSchedModel()->MispredictPenalty;
11961195

@@ -1217,7 +1216,7 @@ SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
12171216
// TrueCost * TrueProbability + FalseCost * FalseProbability.
12181217
ScaledNumber<uint64_t>
12191218
SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
1220-
SelectLike SI) {
1219+
const SelectLike SI) {
12211220
Scaled64 PredPathCost;
12221221
uint64_t TrueWeight, FalseWeight;
12231222
if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
@@ -1237,7 +1236,7 @@ SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
12371236
return PredPathCost;
12381237
}
12391238

1240-
bool SelectOptimizeImpl::isSelectKindSupported(SelectLike SI) {
1239+
bool SelectOptimizeImpl::isSelectKindSupported(const SelectLike SI) {
12411240
bool VectorCond = !SI.getCondition()->getType()->isIntegerTy(1);
12421241
if (VectorCond)
12431242
return false;

llvm/test/CodeGen/AArch64/selectopt.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
; RUN: opt -select-optimize -mtriple=aarch64-linux-gnu -mcpu=neoverse-n1 -S < %s | FileCheck %s --check-prefix=CHECKOO
77
; RUN: opt -select-optimize -mtriple=aarch64-linux-gnu -mcpu=cortex-a710 -S < %s | FileCheck %s --check-prefix=CHECKOO
88
; RUN: opt -select-optimize -mtriple=aarch64-linux-gnu -mcpu=neoverse-v2 -S < %s | FileCheck %s --check-prefix=CHECKOO
9+
; RUN: opt -debugify-and-strip-all-safe -select-optimize -mtriple=aarch64-linux-gnu -mcpu=generic -S < %s | FileCheck %s --check-prefix=CHECKOO
910
; RUN: opt -passes='require<profile-summary>,function(select-optimize)' -mtriple=aarch64-linux-gnu -mcpu=generic -S < %s | FileCheck %s --check-prefix=CHECKOO
1011
; RUN: opt -passes='require<profile-summary>,function(select-optimize)' -mtriple=aarch64-linux-gnu -mcpu=cortex-a55 -S < %s | FileCheck %s --check-prefix=CHECKII
1112
; RUN: opt -passes='require<profile-summary>,function(select-optimize)' -mtriple=aarch64-linux-gnu -mcpu=cortex-a510 -S < %s | FileCheck %s --check-prefix=CHECKII

0 commit comments

Comments
 (0)