<div dir="ltr">On Tue, Jun 18, 2013 at 12:51 PM, Akira Hatanaka <span dir="ltr"><<a href="mailto:ahatanak@gmail.com" target="_blank">ahatanak@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><a href="http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/148393" target="_blank">http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/148393</a><br>
</div></div><div><br></div>Several people suggested the mips-specific sqrt optimization pass committed in r183892 be moved to simplifylibcall, so here are my new patches.<div>
<br></div><div>- opt-sqrt-simplify-lib.patch</div><div>This patch moves the code that currently resides in Mips<span style="line-height:19px;text-align:justify">OptimizeMathLibCalls.cpp</span> 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.  </div>

<div><br></div><div>- opt-sqrt-target-transform.patch</div><div>This patch adds a virtual function optimizeLibCall to TargetTransformInfo. Targets should override this function if they wish to have the libcall optimized. </div>

<div><br></div><div>- opt-sqrt-mips.patch</div><div>This patch adds class MipsTargetTransformInfo and overrides function optimizeLibCall. I plan to delete Mips<span style="line-height:19px;text-align:justify">OptimizeMathLibCalls.cpp once optimization is move to simplifylibcalls.</span></div>

<div><span style="line-height:19px;text-align:justify"><br></span></div><div style="text-align:justify"><span style="line-height:19px"><br></span></div><div style="text-align:justify"><span style="line-height:19px">Two questions:</span></div>

<div style="text-align:justify"><span style="line-height:19px">1. I wasn't sure if it was right to implement this optimization in </span>Scalar/SimplifyLibCalls.cpp, since, a<span style="line-height:19px">ccording to the commit messages I read, S</span>calar/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?</div>
</div></blockquote><div><br></div><div><span style="text-align:justify">Scalar/SimplifyLibCalls.cpp is basically already dead; I'm surprised nobody deleted it already.</span></div><div><span style="text-align:justify"><br>
</span></div><div><span style="text-align:justify">I can't think of any pass that's really suitable; you might just need to add a new pass.</span></div><div> </div><div>-Eli</div></div></div></div>