[llvm-bugs] [Bug 35600] New: Missed optimization in math expression: sqrt(sqrt(a)) == pow(a, 1/4)

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 10 06:52:19 PST 2017


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

            Bug ID: 35600
           Summary: Missed optimization in math expression: sqrt(sqrt(a))
                    == pow(a, 1/4)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: zamazan4ik at tut.by
                CC: llvm-bugs at lists.llvm.org

clang(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags for this
code:


#include <cmath>

double test(double a)
{
    return sqrt(sqrt(a));
}


generates this assembly:


test(double): # @test(double)
  vsqrtsd xmm0, xmm0, xmm0
  vsqrtsd xmm0, xmm0, xmm0
  ret


But there is formula: sqrt(sqrt(a)) == pow(a, 1/4). And it can be compiled in
faster way.

-- 
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/20171210/84d72904/attachment.html>


More information about the llvm-bugs mailing list