summaryrefslogtreecommitdiff
path: root/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:41:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:41:05 +0000
commit01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch)
tree4def12e759965de927d963ac65840d663ef9d1ea /lib/Analysis/CostModel.cpp
parentf0f4822ed4b66e3579e92a89f368f8fb860e218e (diff)
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";
}
}
}