1; RUN: llc < %s -march=x86-64 -enable-unsafe-fp-math | FileCheck %s
2
3define double @exact(double %x) {
4; Exact division by a constant converted to multiplication.
5; CHECK: @exact
6; CHECK: mulsd
7  %div = fdiv double %x, 2.0
8  ret double %div
9}
10
11define double @inexact(double %x) {
12; Inexact division by a constant converted to multiplication.
13; CHECK: @inexact
14; CHECK: mulsd
15  %div = fdiv double %x, 0x41DFFFFFFFC00000
16  ret double %div
17}
18
19define double @funky(double %x) {
20; No conversion to multiplication if too funky.
21; CHECK: @funky
22; CHECK: divsd
23  %div = fdiv double %x, 0.0
24  ret double %div
25}
26
27define double @denormal1(double %x) {
28; Don't generate multiplication by a denormal.
29; CHECK: @denormal1
30; CHECK: divsd
31  %div = fdiv double %x, 0x7FD0000000000001
32  ret double %div
33}
34
35define double @denormal2(double %x) {
36; Don't generate multiplication by a denormal.
37; CHECK: @denormal
38; CHECK: divsd
39  %div = fdiv double %x, 0x7FEFFFFFFFFFFFFF
40  ret double %div
41}
42