llvm-6502/test/CodeGen/X86/fdiv.ll
Duncan Sands 961d666be4 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154265 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-07 20:04:00 +00:00

33 lines
792 B
LLVM

; 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
}