[PATCH] fold: sqrt(x * x * y) -> fabs(x) * sqrt(y)
Sanjay Patel
spatel at rotateright.com
Tue Oct 14 15:32:00 PDT 2014
Hi beanz, hfinkel, mcrosier,
If a square root call has an FP multiplication argument that can be reassociated,
then we can hoist a repeated factor out of the square root call and into a fabs().
In the simplest case, this:
y = sqrt(x * x);
becomes this:
y = fabs(x);
This patch relies on an earlier optimization in instcombine or reassociate to put the
multiplication tree into a canonical form, so we don't have to search over
every permutation of the multiplication tree.
http://reviews.llvm.org/D5787
Files:
include/llvm/Transforms/Utils/SimplifyLibCalls.h
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/InstCombine/fast-math.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5787.14898.patch
Type: text/x-patch
Size: 10466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141014/18bcadf1/attachment.bin>
More information about the llvm-commits
mailing list