[PATCH] D21127: Remove redundant FMUL in Newton-Raphson SQRT code

Nikolai Bozhenov via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 05:36:45 PDT 2016


n.bozhenov created this revision.
n.bozhenov added reviewers: zansari, DavidKreitzer, zinovy.nis, bogner, spatel, hfinkel, andreadb.
n.bozhenov added a subscriber: llvm-commits.

When calculating a square root using Newton-Raphson with two constants,
a naive implementation is to use five multiplications (four muls to calculate
reciprocal square root and another one to calculate the square root itself).
However, after some reassociation and CSE the same result can be obtained
with only four multiplications. Unfortunately, there's no reliable way to do
such a reassociation in the back-end. So, the patch modifies NR code itself
so that it directly builds optimal code for SQRT and doesn't rely on any
further reassociation.

http://reviews.llvm.org/D21127

Files:
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  test/CodeGen/X86/sqrt-fastmath.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21127.60018.patch
Type: text/x-patch
Size: 11128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160608/394d9581/attachment.bin>


More information about the llvm-commits mailing list