[X86] Remove special validation for INT immediate operand from AsmParser. Instead...
[oota-llvm.git] / test / CodeGen / X86 / fdiv-combine.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 | FileCheck %s
2
3 ; Anything more than one division using a single divisor operand
4 ; should be converted into a reciprocal and multiplication.
5
6 define float @div1_arcp(float %x, float %y, float %z) #0 {
7 ; CHECK-LABEL: div1_arcp:
8 ; CHECK:       # BB#0:
9 ; CHECK-NEXT:    divss %xmm1, %xmm0
10 ; CHECK-NEXT:    retq
11   %div1 = fdiv arcp float %x, %y
12   ret float %div1
13 }
14
15 define float @div2_arcp(float %x, float %y, float %z) #0 {
16 ; CHECK-LABEL: div2_arcp:
17 ; CHECK:       # BB#0:
18 ; CHECK-NEXT:    movss {{.*#+}} xmm3 = mem[0],zero,zero,zero
19 ; CHECK-NEXT:    divss %xmm2, %xmm3
20 ; CHECK-NEXT:    mulss %xmm1, %xmm0
21 ; CHECK-NEXT:    mulss %xmm3, %xmm0
22 ; CHECK-NEXT:    mulss %xmm3, %xmm0
23 ; CHECK-NEXT:    retq
24   %div1 = fdiv arcp float %x, %z
25   %mul = fmul arcp float %div1, %y
26   %div2 = fdiv arcp float %mul, %z
27   ret float %div2
28 }
29
30 ; If the reciprocal is already calculated, we should not
31 ; generate an extra multiplication by 1.0. 
32
33 define double @div3_arcp(double %x, double %y, double %z) #0 {
34 ; CHECK-LABEL: div3_arcp:
35 ; CHECK:       # BB#0:
36 ; CHECK-NEXT:    movsd{{.*#+}} xmm2 = mem[0],zero
37 ; CHECK-NEXT:    divsd %xmm1, %xmm2
38 ; CHECK-NEXT:    mulsd %xmm2, %xmm0
39 ; CHECK-NEXT:    addsd %xmm2, %xmm0
40 ; CHECK-NEXT:    retq
41   %div1 = fdiv fast double 1.0, %y
42   %div2 = fdiv fast double %x, %y
43   %ret = fadd fast double %div2, %div1
44   ret double %ret
45 }
46
47 define void @PR24141() #0 {
48 ; CHECK-LABEL: PR24141:
49 ; CHECK:        callq
50 ; CHECK-NEXT:   divsd
51 ; CHECK-NEXT:   jmp
52 entry:
53   br label %while.body
54
55 while.body:
56   %x.0 = phi double [ undef, %entry ], [ %div, %while.body ]
57   %call = call { double, double } @g(double %x.0)
58   %xv0 = extractvalue { double, double } %call, 0
59   %xv1 = extractvalue { double, double } %call, 1
60   %div = fdiv double %xv0, %xv1
61   br label %while.body
62 }
63
64 declare { double, double } @g(double)
65
66 ; FIXME: If the backend understands 'arcp', then this attribute is unnecessary.
67 attributes #0 = { "unsafe-fp-math"="true" }