[llvm-commits] [llvm] r108639 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Owen Anderson resistor at mac.com
Sun Jul 18 11:21:14 PDT 2010


On Jul 18, 2010, at 10:50 AM, Chris Lattner wrote:

> 
> On Jul 18, 2010, at 1:47 AM, Owen Anderson wrote:
> 
>> Author: resistor
>> Date: Sun Jul 18 03:47:54 2010
>> New Revision: 108639
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=108639&view=rev
>> Log:
>> Add a DAGCombine xform to fold away redundant float->double->float conversions around sqrt instructions.
>> I am assured by people more knowledgeable than me that there are no rounding issues in eliminating this.
>> 
>> This fixed <rdar://problem/8197504>.
> 
> Why a dag combine?  I thought that instcombine or simplifylibcalls already did this?  Doing this in the optimizer exposes other opportunities (e.g. when it is cross-block).

The code this comes from is of the form:

double foo(double x) {
  return sqrt(x);
}

The call to sqrt() does not get eliminated from the IR before it hits code-gen, so InstCombine definitely won't be doing anything about it.  We could conceivably have SimplifyLibCalls convert sqrt() into an intrinsic on platforms where it's supported, and then have InstCombine optimize this extend->sqrt->round patten, but SelectionDAG is basically doing the same thing (converts sqrt() to intrinsic, and then we can optimize it there).

--Owen



More information about the llvm-commits mailing list