diff options
| author | Duncan Sands <baldrick@free.fr> | 2012-04-07 20:04:00 +0000 |
|---|---|---|
| committer | Duncan Sands <baldrick@free.fr> | 2012-04-07 20:04:00 +0000 |
| commit | 5f8397a9344aafd3591f03d1dbb93688d1fee728 (patch) | |
| tree | 6dd69d749f106dc7b469c4faeb47b7d38387f187 /llvm/test/CodeGen/X86 | |
| parent | 75a1cf327a96f1b1ea9a033a1d80fd49830ddaac (diff) | |
| download | bcm5719-llvm-5f8397a9344aafd3591f03d1dbb93688d1fee728.tar.gz bcm5719-llvm-5f8397a9344aafd3591f03d1dbb93688d1fee728.zip | |
Convert floating point division by a constant into multiplication by the
reciprocal if converting to the reciprocal is exact. Do it even if inexact
if -ffast-math. This substantially speeds up ac.f90 from the polyhedron
benchmarks.
llvm-svn: 154265
Diffstat (limited to 'llvm/test/CodeGen/X86')
| -rw-r--r-- | llvm/test/CodeGen/X86/fdiv.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/fdiv.ll b/llvm/test/CodeGen/X86/fdiv.ll new file mode 100644 index 00000000000..553f14efa13 --- /dev/null +++ b/llvm/test/CodeGen/X86/fdiv.ll @@ -0,0 +1,32 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; RUN: llc < %s -march=x86-64 -enable-unsafe-fp-math | FileCheck -check-prefix=UNSAFE %s + +define double @exact(double %x) { +; Exact division by a constant always converted to multiplication. +; CHECK: @exact +; CHECK: mulsd +; UNSAFE: @exact +; UNSAFE: mulsd + %div = fdiv double %x, 2.0 + ret double %div +} + +define double @inexact(double %x) { +; Inexact division by a constant converted to multiplication if unsafe-math. +; CHECK: @inexact +; CHECK: divsd +; UNSAFE: @inexact +; UNSAFE: mulsd + %div = fdiv double %x, 0x41DFFFFFFFC00000 + ret double %div +} + +define double @funky(double %x) { +; No conversion to multiplication if too funky. +; CHECK: @funky +; CHECK: divsd +; UNSAFE: @funky +; UNSAFE: divsd + %div = fdiv double %x, 0.0 + ret double %div +} |

