[PATCH] Optimize call to sqrt.

Eli Friedman eli.friedman at gmail.com
Tue Jun 18 13:37:21 PDT 2013


On Tue, Jun 18, 2013 at 12:51 PM, Akira Hatanaka <ahatanak at gmail.com> wrote:

> http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/148393
>
> Several people suggested the mips-specific sqrt optimization pass
> committed in r183892 be moved to simplifylibcall, so here are my new
> patches.
>
> - opt-sqrt-simplify-lib.patch
> This patch moves the code that currently resides in Mips
> OptimizeMathLibCalls.cpp to Scalar/SimplifyLibCalls.cpp. I was initially
> considering implementing this optimization in Utils/SimplifyLibCalls.cpp,
> but since the optimization in Utils/SimplifyLibCalls.cpp is run during
> instcombine and instcombine cannot handle optimization that changes the
> CFG, I decided to do this in Scalar/SimplifyLibCalls.cpp.
>
> - opt-sqrt-target-transform.patch
> This patch adds a virtual function optimizeLibCall to TargetTransformInfo.
> Targets should override this function if they wish to have the libcall
> optimized.
>
> - opt-sqrt-mips.patch
> This patch adds class MipsTargetTransformInfo and overrides
> function optimizeLibCall. I plan to delete MipsOptimizeMathLibCalls.cpp
> once optimization is move to simplifylibcalls.
>
>
> Two questions:
> 1. I wasn't sure if it was right to implement this optimization in Scalar/SimplifyLibCalls.cpp,
> since, according to the commit messages I read, Scalar/SimplifyLibCalls.cpp
> was going to be removed once the migration to instcombine was complete. Are
> there any places other than Scalar/SimplifyLibCalls.cpp or
> Utils/SimplifyLibCalls.cpp that can implement this optimization?
>

Scalar/SimplifyLibCalls.cpp is basically already dead; I'm surprised nobody
deleted it already.

I can't think of any pass that's really suitable; you might just need to
add a new pass.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130618/51e2c5a0/attachment.html>


More information about the llvm-commits mailing list