[llvm-dev] The most efficient way to implement an integer based power function pow in LLVM
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Thu Jan 12 09:58:41 PST 2017
On 1/12/2017 9:33 AM, Mehdi Amini via llvm-dev wrote:
>> On Jan 12, 2017, at 5:03 AM, Antoine Pitrou via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> On Mon, 9 Jan 2017 11:43:17 -0600
>> Wei Ding via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>> I want an efficient way to implement function pow in LLVM instead of
>>> invoking pow() math built-in. For algorithm part, I am clear for the logic.
>>> But I am not quite sure for which parts of LLVM should I replace built-in
>>> pow with another efficient pow implementation. Any comments and feedback
>>> are appreciated. Thanks!
>> In Numba, we have decided to optimize some usages of the power function
>> in our own front-end, so that LLVM IR gets an already optimized form,
>> as we have found that otherwise LLVM may miss some optimization
>> opportunities. YMMV.
> It seems to me that it would be more interesting to gather these misoptimization and fix LLVM to catch them.
>> (e.g. we detect that the exponent is a compile-time constant and
>> transform `x**3` into `x*x*x`)
> This seems definitely in the scope of what LLVM could do, potentially with TTI.
LLVM already does this... but only if the pow() call is marked "fast".
IEEE 754 pow() is supposed to be correctly rounded, but (x*x)*x has an
extra rounding step.
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-dev