[llvm-bugs] [Bug 46406] New: [X86] rsqrt and div generated for 1/sqrt(x * x * x) with -Ofast

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 19 15:02:05 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46406

            Bug ID: 46406
           Summary: [X86] rsqrt and div generated for 1/sqrt(x * x * x)
                    with -Ofast
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

InstCombine transforms sqrt(x * x * x) into fabs(x) * sqrt(x) under fast math.

This means (1 / sqrt(x*x*x)) becomes (1 / (fabs(x) * sqrt(x))) which the
backend is unable to match to reciprocal sqrt approximation. Instead we do a
square root approximation which uses rsqrt followed by a regular divide.

Ideally we'd just do the x*x*x and then approximate the reciprocal square root
of that.

https://godbolt.org/z/fR66c4

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200619/90b2258d/attachment.html>


More information about the llvm-bugs mailing list