@@ -244,22 +244,25 @@ class SelectOptimizeImpl {
244
244
Scaled64 getTrueOpCost (DenseMap<const Instruction *, CostInfo> &InstCostMap,
245
245
const TargetTransformInfo *TTI) {
246
246
if (isa<SelectInst>(I))
247
- if (auto *I = dyn_cast<Instruction>(getTrueValue ()))
248
- return InstCostMap.contains (I) ? InstCostMap[I].NonPredCost
247
+ if (auto *I = dyn_cast<Instruction>(getTrueValue ())) {
248
+ auto It = InstCostMap.find (I);
249
+ return It != InstCostMap.end () ? It->second .NonPredCost
249
250
: Scaled64::getZero ();
251
+ }
250
252
251
253
// Or case - add the cost of an extra Or to the cost of the False case.
252
254
if (isa<BinaryOperator>(I))
253
- if (auto I = dyn_cast<Instruction>(getFalseValue ()))
254
- if (InstCostMap.contains (I)) {
255
+ if (auto I = dyn_cast<Instruction>(getFalseValue ())) {
256
+ auto It = InstCostMap.find (I);
257
+ if (It != InstCostMap.end ()) {
255
258
InstructionCost OrCost = TTI->getArithmeticInstrCost (
256
259
Instruction::Or, I->getType (), TargetTransformInfo::TCK_Latency,
257
260
{TargetTransformInfo::OK_AnyValue,
258
261
TargetTransformInfo::OP_None},
259
262
{TTI::OK_UniformConstantValue, TTI::OP_PowerOf2});
260
- return InstCostMap[I].NonPredCost +
261
- Scaled64::get (*OrCost.getValue ());
263
+ return It->second .NonPredCost + Scaled64::get (*OrCost.getValue ());
262
264
}
265
+ }
263
266
264
267
return Scaled64::getZero ();
265
268
}
@@ -270,15 +273,17 @@ class SelectOptimizeImpl {
270
273
getFalseOpCost (DenseMap<const Instruction *, CostInfo> &InstCostMap,
271
274
const TargetTransformInfo *TTI) {
272
275
if (isa<SelectInst>(I))
273
- if (auto *I = dyn_cast<Instruction>(getFalseValue ()))
274
- return InstCostMap.contains (I) ? InstCostMap[I].NonPredCost
276
+ if (auto *I = dyn_cast<Instruction>(getFalseValue ())) {
277
+ auto It = InstCostMap.find (I);
278
+ return It != InstCostMap.end () ? It->second .NonPredCost
275
279
: Scaled64::getZero ();
280
+ }
276
281
277
282
// Or case - return the cost of the false case
278
283
if (isa<BinaryOperator>(I))
279
284
if (auto I = dyn_cast<Instruction>(getFalseValue ()))
280
- if (InstCostMap.contains (I ))
281
- return InstCostMap[I] .NonPredCost ;
285
+ if (auto It = InstCostMap.find (I); It != InstCostMap. end ( ))
286
+ return It-> second .NonPredCost ;
282
287
283
288
return Scaled64::getZero ();
284
289
}
0 commit comments