summaryrefslogtreecommitdiff
path: root/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/CostModel.cpp')
-rw-r--r--lib/Analysis/CostModel.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp
index 0383cbfbbe4cd..68a4bea96baa4 100644
--- a/lib/Analysis/CostModel.cpp
+++ b/lib/Analysis/CostModel.cpp
@@ -504,8 +504,12 @@ unsigned CostModelAnalysis::getInstructionCost(const Instruction *I) const {
for (unsigned J = 0, JE = II->getNumArgOperands(); J != JE; ++J)
Args.push_back(II->getArgOperand(J));
+ FastMathFlags FMF;
+ if (auto *FPMO = dyn_cast<FPMathOperator>(II))
+ FMF = FPMO->getFastMathFlags();
+
return TTI->getIntrinsicInstrCost(II->getIntrinsicID(), II->getType(),
- Args);
+ Args, FMF);
}
return -1;
default:
@@ -518,16 +522,15 @@ void CostModelAnalysis::print(raw_ostream &OS, const Module*) const {
if (!F)
return;
- for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) {
- for (BasicBlock::iterator it = B->begin(), e = B->end(); it != e; ++it) {
- Instruction *Inst = &*it;
- unsigned Cost = getInstructionCost(Inst);
+ for (BasicBlock &B : *F) {
+ for (Instruction &Inst : B) {
+ unsigned Cost = getInstructionCost(&Inst);
if (Cost != (unsigned)-1)
OS << "Cost Model: Found an estimated cost of " << Cost;
else
OS << "Cost Model: Unknown cost";
- OS << " for instruction: "<< *Inst << "\n";
+ OS << " for instruction: " << Inst << "\n";
}
}
}