@@ -210,8 +210,8 @@ bool SpeculativeExecutionPass::runOnBasicBlock(BasicBlock &B) {
210
210
return false ;
211
211
}
212
212
213
- static unsigned ComputeSpeculationCost (const Instruction *I,
214
- const TargetTransformInfo &TTI) {
213
+ static InstructionCost ComputeSpeculationCost (const Instruction *I,
214
+ const TargetTransformInfo &TTI) {
215
215
switch (Operator::getOpcode (I)) {
216
216
case Instruction::GetElementPtr:
217
217
case Instruction::Add:
@@ -255,7 +255,8 @@ static unsigned ComputeSpeculationCost(const Instruction *I,
255
255
return TTI.getUserCost (I, TargetTransformInfo::TCK_SizeAndLatency);
256
256
257
257
default :
258
- return UINT_MAX; // Disallow anything not explicitly listed.
258
+ return InstructionCost::getInvalid (); // Disallow anything not explicitly
259
+ // listed.
259
260
}
260
261
}
261
262
@@ -288,11 +289,11 @@ bool SpeculativeExecutionPass::considerHoistingFromTo(
288
289
return true ;
289
290
};
290
291
291
- unsigned TotalSpeculationCost = 0 ;
292
+ InstructionCost TotalSpeculationCost = 0 ;
292
293
unsigned NotHoistedInstCount = 0 ;
293
294
for (const auto &I : FromBlock) {
294
- const unsigned Cost = ComputeSpeculationCost (&I, *TTI);
295
- if (Cost != UINT_MAX && isSafeToSpeculativelyExecute (&I) &&
295
+ const InstructionCost Cost = ComputeSpeculationCost (&I, *TTI);
296
+ if (Cost. isValid () && isSafeToSpeculativelyExecute (&I) &&
296
297
AllPrecedingUsesFromBlockHoisted (&I)) {
297
298
TotalSpeculationCost += Cost;
298
299
if (TotalSpeculationCost > SpecExecMaxSpeculationCost)
0 commit comments