aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 7f1709e10f..0d5be26a5e 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -1293,10 +1293,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BIpow:
case Builtin::BIpowf:
case Builtin::BIpowl: {
- // LOCALMOD: For PNACl we don't want pow* calls to ever turn into
- // intrinsics. We want them to be resolved vs. the newlib implementation
- // within the pexe during bitcode linking.
- // TODO(eliben): upstream this
+ // Transform a call to pow* into a @llvm.pow.* intrinsic call, but only
+ // if the target agrees.
+ if (getTargetHooks().emitIntrinsicForPow()) {
+ if (!FD->hasAttr<ConstAttr>())
+ break;
+ Value *Base = EmitScalarExpr(E->getArg(0));
+ Value *Exponent = EmitScalarExpr(E->getArg(1));
+ llvm::Type *ArgType = Base->getType();
+ Value *F = CGM.getIntrinsic(Intrinsic::pow, ArgType);
+ return RValue::get(Builder.CreateCall2(F, Base, Exponent));
+ }
break;
}