Duncan Sands | 961d666 | 2012-04-07 20:04:00 +0000 | [diff] [blame^] | 1 | ; RUN: llc < %s -march=x86-64 | FileCheck %s |
| 2 | ; RUN: llc < %s -march=x86-64 -enable-unsafe-fp-math | FileCheck -check-prefix=UNSAFE %s |
| 3 | |
| 4 | define double @exact(double %x) { |
| 5 | ; Exact division by a constant always converted to multiplication. |
| 6 | ; CHECK: @exact |
| 7 | ; CHECK: mulsd |
| 8 | ; UNSAFE: @exact |
| 9 | ; UNSAFE: mulsd |
| 10 | %div = fdiv double %x, 2.0 |
| 11 | ret double %div |
| 12 | } |
| 13 | |
| 14 | define double @inexact(double %x) { |
| 15 | ; Inexact division by a constant converted to multiplication if unsafe-math. |
| 16 | ; CHECK: @inexact |
| 17 | ; CHECK: divsd |
| 18 | ; UNSAFE: @inexact |
| 19 | ; UNSAFE: mulsd |
| 20 | %div = fdiv double %x, 0x41DFFFFFFFC00000 |
| 21 | ret double %div |
| 22 | } |
| 23 | |
| 24 | define double @funky(double %x) { |
| 25 | ; No conversion to multiplication if too funky. |
| 26 | ; CHECK: @funky |
| 27 | ; CHECK: divsd |
| 28 | ; UNSAFE: @funky |
| 29 | ; UNSAFE: divsd |
| 30 | %div = fdiv double %x, 0.0 |
| 31 | ret double %div |
| 32 | } |