#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Config/config.h"
using namespace llvm;
if (Op2C == 0) return 0;
if (Op2C->getValueAPF().isZero()) // pow(x, 0.0) -> 1.0
- return Context->getConstantFP(CI->getType(), 1.0);
+ return ConstantFP::get(CI->getType(), 1.0);
if (Op2C->isExactlyValue(0.5)) {
// FIXME: This is not safe for -0.0 and -inf. This can only be done when
if (Op2C->isExactlyValue(2.0)) // pow(x, 2.0) -> x*x
return B.CreateFMul(Op1, Op1, "pow2");
if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x
- return B.CreateFDiv(Context->getConstantFP(CI->getType(), 1.0),
+ return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0),
Op1, "powrecip");
return 0;
}
else
Name = "ldexpl";
- Constant *One = Context->getConstantFP(APFloat(1.0f));
+ Constant *One = ConstantFP::get(*Context, APFloat(1.0f));
if (Op->getType() != Type::FloatTy)
One = Context->getConstantExprFPExtend(One, Op->getType());
continue;
// Ignore unknown calls.
- const char *CalleeName = Callee->getNameStart();
- StringMap<LibCallOptimization*>::iterator OMI =
- Optimizations.find(StringRef(CalleeName, Callee->getNameLen()));
- if (OMI == Optimizations.end()) continue;
+ LibCallOptimization *LCO = Optimizations.lookup(Callee->getName());
+ if (!LCO) continue;
// Set the builder to the instruction after the call.
Builder.SetInsertPoint(BB, I);
// Try to optimize this call.
- Value *Result = OMI->second->OptimizeCall(CI, TD, Builder);
+ Value *Result = LCO->OptimizeCall(CI, TD, Builder);
if (Result == 0) continue;
- DEBUG(DOUT << "SimplifyLibCalls simplified: " << *CI;
- DOUT << " into: " << *Result << "\n");
+ DEBUG(errs() << "SimplifyLibCalls simplified: " << *CI;
+ errs() << " into: " << *Result << "\n");
// Something changed!
Changed = true;