Skip to content

Commit 23886bd

Browse files
committed
More const's and a debug run line
1 parent f76d584 commit 23886bd

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 {
@@ -897,7 +896,7 @@ static InstructionCost divideNearest(InstructionCost Numerator,
897896
return (Numerator + (Denominator / 2)) / Denominator;
898897
}
899898

900-
static bool extractBranchWeights(SelectOptimizeImpl::SelectLike SI,
899+
static bool extractBranchWeights(const SelectOptimizeImpl::SelectLike SI,
901900
uint64_t &TrueVal, uint64_t &FalseVal) {
902901
if (isa<SelectInst>(SI.getI()))
903902
return extractBranchWeights(*SI.getI(), TrueVal, FalseVal);
@@ -1025,7 +1024,7 @@ void SelectOptimizeImpl::getExclBackwardsSlice(Instruction *I,
10251024
}
10261025
}
10271026

1028-
bool SelectOptimizeImpl::isSelectHighlyPredictable(SelectLike SI) {
1027+
bool SelectOptimizeImpl::isSelectHighlyPredictable(const SelectLike SI) {
10291028
uint64_t TrueWeight, FalseWeight;
10301029
if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
10311030
uint64_t Max = std::max(TrueWeight, FalseWeight);
@@ -1207,7 +1206,7 @@ SelectOptimizeImpl::computeInstCost(const Instruction *I) {
12071206
}
12081207

12091208
ScaledNumber<uint64_t>
1210-
SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
1209+
SelectOptimizeImpl::getMispredictionCost(const SelectLike SI,
12111210
const Scaled64 CondCost) {
12121211
uint64_t MispredictPenalty = TSchedModel.getMCSchedModel()->MispredictPenalty;
12131212

@@ -1234,7 +1233,7 @@ SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
12341233
// TrueCost * TrueProbability + FalseCost * FalseProbability.
12351234
ScaledNumber<uint64_t>
12361235
SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
1237-
SelectLike SI) {
1236+
const SelectLike SI) {
12381237
Scaled64 PredPathCost;
12391238
uint64_t TrueWeight, FalseWeight;
12401239
if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
@@ -1254,7 +1253,7 @@ SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
12541253
return PredPathCost;
12551254
}
12561255

1257-
bool SelectOptimizeImpl::isSelectKindSupported(SelectLike SI) {
1256+
bool SelectOptimizeImpl::isSelectKindSupported(const SelectLike SI) {
12581257
bool VectorCond = !SI.getCondition()->getType()->isIntegerTy(1);
12591258
if (VectorCond)
12601259
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)