diff options
author | Davide Italiano <davide@freebsd.org> | 2015-11-04 23:36:56 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2015-11-04 23:36:56 +0000 |
commit | 51507d2ad84683daa77d202141d0a63ff94ae9d6 (patch) | |
tree | 799c6d45abf918129bbe43185c05850c8f91e0fa /llvm/test | |
parent | e692621a9dc6eff696939a552fe7aa1fed4300ad (diff) | |
download | bcm5719-llvm-51507d2ad84683daa77d202141d0a63ff94ae9d6.tar.gz bcm5719-llvm-51507d2ad84683daa77d202141d0a63ff94ae9d6.zip |
[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
llvm-svn: 252098
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstCombine/tan-nofastmath.ll | 17 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/tan.ll | 15 |
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/tan-nofastmath.ll b/llvm/test/Transforms/InstCombine/tan-nofastmath.ll new file mode 100644 index 00000000000..0fe7b2c1d52 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/tan-nofastmath.ll @@ -0,0 +1,17 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +define float @mytan(float %x) { +entry: + %call = call float @atanf(float %x) + %call1 = call float @tanf(float %call) + ret float %call1 +} + +; CHECK-LABEL: define float @mytan( +; CHECK: %call = call float @atanf(float %x) +; CHECK-NEXT: %call1 = call float @tanf(float %call) +; CHECK-NEXT: ret float %call1 +; CHECK-NEXT: } + +declare float @tanf(float) +declare float @atanf(float) diff --git a/llvm/test/Transforms/InstCombine/tan.ll b/llvm/test/Transforms/InstCombine/tan.ll new file mode 100644 index 00000000000..58e3bb355bd --- /dev/null +++ b/llvm/test/Transforms/InstCombine/tan.ll @@ -0,0 +1,15 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s + +define float @mytan(float %x) #0 { +entry: + %call = call float @atanf(float %x) + %call1 = call float @tanf(float %call) + ret float %call1 +} + +; CHECK-LABEL: define float @mytan( +; CHECK: ret float %x + +declare float @tanf(float) #0 +declare float @atanf(float) #0 +attributes #0 = { "unsafe-fp-math"="true" } |