@@ -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 {
@@ -897,7 +896,7 @@ static InstructionCost divideNearest(InstructionCost Numerator,
897
896
return (Numerator + (Denominator / 2 )) / Denominator;
898
897
}
899
898
900
- static bool extractBranchWeights (SelectOptimizeImpl::SelectLike SI,
899
+ static bool extractBranchWeights (const SelectOptimizeImpl::SelectLike SI,
901
900
uint64_t &TrueVal, uint64_t &FalseVal) {
902
901
if (isa<SelectInst>(SI.getI ()))
903
902
return extractBranchWeights (*SI.getI (), TrueVal, FalseVal);
@@ -1025,7 +1024,7 @@ void SelectOptimizeImpl::getExclBackwardsSlice(Instruction *I,
1025
1024
}
1026
1025
}
1027
1026
1028
- bool SelectOptimizeImpl::isSelectHighlyPredictable (SelectLike SI) {
1027
+ bool SelectOptimizeImpl::isSelectHighlyPredictable (const SelectLike SI) {
1029
1028
uint64_t TrueWeight, FalseWeight;
1030
1029
if (extractBranchWeights (SI, TrueWeight, FalseWeight)) {
1031
1030
uint64_t Max = std::max (TrueWeight, FalseWeight);
@@ -1207,7 +1206,7 @@ SelectOptimizeImpl::computeInstCost(const Instruction *I) {
1207
1206
}
1208
1207
1209
1208
ScaledNumber<uint64_t >
1210
- SelectOptimizeImpl::getMispredictionCost (SelectLike SI,
1209
+ SelectOptimizeImpl::getMispredictionCost (const SelectLike SI,
1211
1210
const Scaled64 CondCost) {
1212
1211
uint64_t MispredictPenalty = TSchedModel.getMCSchedModel ()->MispredictPenalty ;
1213
1212
@@ -1234,7 +1233,7 @@ SelectOptimizeImpl::getMispredictionCost(SelectLike SI,
1234
1233
// TrueCost * TrueProbability + FalseCost * FalseProbability.
1235
1234
ScaledNumber<uint64_t >
1236
1235
SelectOptimizeImpl::getPredictedPathCost (Scaled64 TrueCost, Scaled64 FalseCost,
1237
- SelectLike SI) {
1236
+ const SelectLike SI) {
1238
1237
Scaled64 PredPathCost;
1239
1238
uint64_t TrueWeight, FalseWeight;
1240
1239
if (extractBranchWeights (SI, TrueWeight, FalseWeight)) {
@@ -1254,7 +1253,7 @@ SelectOptimizeImpl::getPredictedPathCost(Scaled64 TrueCost, Scaled64 FalseCost,
1254
1253
return PredPathCost;
1255
1254
}
1256
1255
1257
- bool SelectOptimizeImpl::isSelectKindSupported (SelectLike SI) {
1256
+ bool SelectOptimizeImpl::isSelectKindSupported (const SelectLike SI) {
1258
1257
bool VectorCond = !SI.getCondition ()->getType ()->isIntegerTy (1 );
1259
1258
if (VectorCond)
1260
1259
return false ;
0 commit comments