[SimplifyLibCalls] Add a new transformation: pow(exp(x), y) -> exp(x*y)
authorDavide Italiano <davide@freebsd.org>
Tue, 3 Nov 2015 20:32:23 +0000 (20:32 +0000)
committerDavide Italiano <davide@freebsd.org>
Tue, 3 Nov 2015 20:32:23 +0000 (20:32 +0000)
commit1b506d8aa4272259540b152a15e64513a44d57de
treea5fe5556e7429da28eea996b771f58be8b5bfbde
parent91c642526e40b77f44a03b99b5d450cd293b78aa
[SimplifyLibCalls] Add a new transformation: pow(exp(x), y) -> exp(x*y)

This one is enabled only under -ffast-math (due to rounding/overflows)
but allows us to emit shorter code.

Before (on FreeBSD x86-64):
4007f0:       50                      push   %rax
4007f1:       f2 0f 11 0c 24          movsd  %xmm1,(%rsp)
4007f6:       e8 75 fd ff ff          callq  400570 <exp2@plt>
4007fb:       f2 0f 10 0c 24          movsd  (%rsp),%xmm1
400800:       58                      pop    %rax
400801:       e9 7a fd ff ff          jmpq   400580 <pow@plt>
400806:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
40080d:       00 00 00

After:
4007b0:       f2 0f 59 c1             mulsd  %xmm1,%xmm0
4007b4:       e9 87 fd ff ff          jmpq   400540 <exp2@plt>
4007b9:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)

Differential Revision: http://reviews.llvm.org/D14045

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251976 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/InstCombine/pow-exp-nofastmath.ll [new file with mode: 0644]
test/Transforms/InstCombine/pow-exp.ll [new file with mode: 0644]
test/Transforms/InstCombine/pow-exp2.ll [new file with mode: 0644]