Skip to content

Commit

Permalink
use pow, powf instead of powi. fixes #6506
Browse files Browse the repository at this point in the history
LLVM seems to be able to optimize small constant powers here too.
the pow intrinsic had the same bug as powi.
  • Loading branch information
JeffBezanson committed May 5, 2014
1 parent aa752ae commit f2b3192
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,10 +1253,14 @@ static Value *emit_intrinsic(intrinsic f, jl_value_t **args, size_t nargs,
HANDLE(powi_llvm,2) {
x = FP(x);
y = JL_INT(y);
Type *ts[1] = { x->getType() };
return builder.CreateCall2(Intrinsic::getDeclaration(jl_Module, Intrinsic::powi,
ArrayRef<Type*>(ts)),
x, y);
Type *tx = x->getType();
// TODO: use powi when LLVM is fixed. issue #6506
// http://llvm.org/bugs/show_bug.cgi?id=19530
Type *ts[2] = { tx, tx };
return builder.
CreateCall2(jl_Module->getOrInsertFunction(tx==T_float64 ? "pow" : "powf",
FunctionType::get(tx, ts, false)),
x, builder.CreateSIToFP(y, tx));
}
default:
assert(false);
Expand Down

0 comments on commit f2b3192

Please sign in to comment.