[llvm-bugs] [Bug 35595] New: Missed optimization in math expression: aggressive optimization with std::pow

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 10 04:43:43 PST 2017


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

            Bug ID: 35595
           Summary: Missed optimization in math expression: aggressive
                    optimization with std::pow
           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, double x)
{
    return pow(a, x) * a * a * a * a;
}

generates this assembly:


test(double, double): # @test(double, double)
  push rax
  vmovsd qword ptr [rsp], xmm0 # 8-byte Spill
  call pow
  vmovsd xmm1, qword ptr [rsp] # 8-byte Reload
  vmulsd xmm1, xmm1, xmm1
  vmulsd xmm1, xmm1, xmm1
  vmulsd xmm0, xmm1, xmm0
  pop rax
  ret


As you can see, me can simplify it by adding 4 to 'x' variable and after call
std::pow.

-- 
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/1c28cc95/attachment.html>


More information about the llvm-bugs mailing list