@@ -128,7 +128,6 @@ class SelectOptimizeImpl {
128
128
// / act like selects. For example Or(Zext(icmp), X) can be treated like
129
129
// / select(icmp, X|1, X).
130
130
class SelectLike {
131
- private:
132
131
SelectLike (Instruction *I) : I(I) {}
133
132
134
133
Instruction *I;
@@ -305,7 +304,7 @@ class SelectOptimizeImpl {
305
304
Instruction *SI, bool ForSinking = false );
306
305
307
306
// Returns true if the condition of the select is highly predictable.
308
- bool isSelectHighlyPredictable (SelectLike SI);
307
+ bool isSelectHighlyPredictable (const SelectLike SI);
309
308
310
309
// Loop-level checks to determine if a non-predicated version (with branches)
311
310
// of the given loop is more profitable than its predicated version.
@@ -325,14 +324,14 @@ class SelectOptimizeImpl {
325
324
std::optional<uint64_t > computeInstCost (const Instruction *I);
326
325
327
326
// 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);
329
328
330
329
// Returns the cost of a branch when the prediction is correct.
331
330
Scaled64 getPredictedPathCost (Scaled64 TrueCost, Scaled64 FalseCost,
332
- SelectLike SI);
331
+ const SelectLike SI);
333
332
334
333
// Returns true if the target architecture supports lowering a given select.
335
- bool isSelectKindSupported (SelectLike SI);
334
+ bool isSelectKindSupported (const SelectLike SI);
336
335
};
337
336
338
337
class SelectOptimize : public FunctionPass {
@@ -880,7 +879,7 @@ static InstructionCost divideNearest(InstructionCost Numerator,
880
879
return (Numerator + (Denominator / 2 )) / Denominator;
881
880
}
882
881
883
- static bool extractBranchWeights (SelectOptimizeImpl::SelectLike SI,
882
+ static bool extractBranchWeights (const SelectOptimizeImpl::SelectLike SI,
884
883
uint64_t &TrueVal, uint64_t &FalseVal) {
885
884
if (isa<SelectInst>(SI.getI ()))
886
885
return extractBranchWeights (*SI.getI (), TrueVal, FalseVal);
@@ -1008,7 +1007,7 @@ void SelectOptimizeImpl::getExclBackwardsSlice(Instruction *I,
1008
1007
}
1009
1008
}
1010
1009
1011
- bool SelectOptimizeImpl::isSelectHighlyPredictable (SelectLike SI) {
1010
+ bool SelectOptimizeImpl::isSelectHighlyPredictable (const SelectLike SI) {
1012
1011
uint64_t TrueWeight, FalseWeight;
1013
1012
if (extractBranchWeights (SI, TrueWeight, FalseWeight)) {
1014
1013
uint64_t Max = std::max (TrueWeight, FalseWeight);
@@ -1190,7 +1189,7 @@ SelectOptimizeImpl::computeInstCost(const Instruction *I) {
1190
1189
}
1191
1190
1192
1191
ScaledNumber<uint64_t >
1193
- SelectOptimizeImpl::getMispredictionCost (SelectLike SI,
1192
+ SelectOptimizeImpl::getMispredictionCost (const SelectLike SI,
1194
1193
const Scaled64 CondCost) {
1195
1194
uint64_t MispredictPenalty = TSchedModel.getMCSchedModel ()->MispredictPenalty ;
1196
1195
@@ -1217,7 +1216,7 @@ SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
1217
1216
// TrueCost * TrueProbability + FalseCost * FalseProbability.
1218
1217
ScaledNumber<uint64_t >
1219
1218
SelectOptimizeImpl::getPredictedPathCost (Scaled64 TrueCost, Scaled64 FalseCost,
1220
- SelectLike SI) {
1219
+ const SelectLike SI) {
1221
1220
Scaled64 PredPathCost;
1222
1221
uint64_t TrueWeight, FalseWeight;
1223
1222
if (extractBranchWeights (SI, TrueWeight, FalseWeight)) {
@@ -1237,7 +1236,7 @@ SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
1237
1236
return PredPathCost;
1238
1237
}
1239
1238
1240
- bool SelectOptimizeImpl::isSelectKindSupported (SelectLike SI) {
1239
+ bool SelectOptimizeImpl::isSelectKindSupported (const SelectLike SI) {
1241
1240
bool VectorCond = !SI.getCondition ()->getType ()->isIntegerTy (1 );
1242
1241
if (VectorCond)
1243
1242
return false ;
0 commit comments