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

            Bug ID: 35706
           Summary: Missed optimization in math expression:
                    log10(pow(10.0,x)) == x
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Clang (trunk) with '-O3 -std=c++17 -ffast-math' for this code:

#include <cmath>

double test10(double x)
{
    return log10(pow(10.0, x));
}

double test2(double x)
{
    return log2(pow(2.0, x));
}


generates this:

.LCPI0_0:
  .quad 4621819117588971520 # double 10
test10(double): # @test10(double)
  push rax
  movaps xmm1, xmm0
  movsd xmm0, qword ptr [rip + .LCPI0_0] # xmm0 = mem[0],zero
  call pow
  pop rax
  jmp log10 # TAILCALL
test2(double): # @test2(double)
  push rax
  call exp2
  pop rax
  jmp log2 # TAILCALL


But we can simplify it by logX(pow(X,Y)) == Y.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to