[SimplifyLibCalls] New transformation: tan(atan(x)) -> x
authorDavide Italiano <davide@freebsd.org>
Wed, 4 Nov 2015 23:36:56 +0000 (23:36 +0000)
committerDavide Italiano <davide@freebsd.org>
Wed, 4 Nov 2015 23:36:56 +0000 (23:36 +0000)
commit9496ef1fefb7a9caa9e5acf9356a59ca5c37c07d
tree2d60b6a67b89e45fff330c5c30bdada2b3c119df
parentd022e94463dc20c060fd91402b8f1819ecc64587
[SimplifyLibCalls] New transformation: tan(atan(x)) -> x

This is enabled only under -ffast-math.
So, instead of emitting:
  4007b0:       50                      push   %rax
  4007b1:       e8 8a fd ff ff          callq  400540 <atanf@plt>
  4007b6:       58                      pop    %rax
  4007b7:       e9 94 fd ff ff          jmpq   400550 <tanf@plt>
  4007bc:       0f 1f 40 00             nopl   0x0(%rax)

for:
float mytan(float x) {
  return tanf(atanf(x));
}
we emit a single retq.

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

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