[TwoAddressInstructionPass] When looking for a 3 addr conversion after commuting...
[oota-llvm.git] / test / CodeGen / X86 / fp-fast.ll
1 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=avx -enable-unsafe-fp-math < %s | FileCheck %s
2
3 define float @test1(float %a) {
4 ; CHECK-LABEL: test1:
5 ; CHECK:       # BB#0:
6 ; CHECK-NEXT:    vmulss {{.*}}(%rip), %xmm0, %xmm0
7 ; CHECK-NEXT:    retq
8   %t1 = fadd float %a, %a
9   %r = fadd float %t1, %t1
10   ret float %r
11 }
12
13 define float @test2(float %a) {
14 ; CHECK-LABEL: test2:
15 ; CHECK:       # BB#0:
16 ; CHECK-NEXT:    vmulss {{.*}}(%rip), %xmm0, %xmm0
17 ; CHECK-NEXT:    retq
18   %t1 = fmul float 4.0, %a
19   %t2 = fadd float %a, %a
20   %r = fadd float %t1, %t2
21   ret float %r
22 }
23
24 define float @test3(float %a) {
25 ; CHECK-LABEL: test3:
26 ; CHECK:       # BB#0:
27 ; CHECK-NEXT:    vmulss {{.*}}(%rip), %xmm0, %xmm0
28 ; CHECK-NEXT:    retq
29   %t1 = fmul float %a, 4.0
30   %t2 = fadd float %a, %a
31   %r = fadd float %t1, %t2
32   ret float %r
33 }
34
35 define float @test4(float %a) {
36 ; CHECK-LABEL: test4:
37 ; CHECK:       # BB#0:
38 ; CHECK-NEXT:    vmulss {{.*}}(%rip), %xmm0, %xmm0
39 ; CHECK-NEXT:    retq
40   %t1 = fadd float %a, %a
41   %t2 = fmul float 4.0, %a
42   %r = fadd float %t1, %t2
43   ret float %r
44 }
45
46 define float @test5(float %a) {
47 ; CHECK-LABEL: test5:
48 ; CHECK:       # BB#0:
49 ; CHECK-NEXT:    vmulss {{.*}}(%rip), %xmm0, %xmm0
50 ; CHECK-NEXT:    retq
51   %t1 = fadd float %a, %a
52   %t2 = fmul float %a, 4.0
53   %r = fadd float %t1, %t2
54   ret float %r
55 }
56
57 define float @test6(float %a) {
58 ; CHECK-LABEL: test6:
59 ; CHECK:       # BB#0:
60 ; CHECK-NEXT:    vxorps %xmm0, %xmm0, %xmm0
61 ; CHECK-NEXT:    retq
62   %t1 = fmul float 2.0, %a
63   %t2 = fadd float %a, %a
64   %r = fsub float %t1, %t2
65   ret float %r
66 }
67
68 define float @test7(float %a) {
69 ; CHECK-LABEL: test7:
70 ; CHECK:       # BB#0:
71 ; CHECK-NEXT:    vxorps %xmm0, %xmm0, %xmm0
72 ; CHECK-NEXT:    retq
73   %t1 = fmul float %a, 2.0
74   %t2 = fadd float %a, %a
75   %r = fsub float %t1, %t2
76   ret float %r
77 }
78
79 define float @test8(float %a) {
80 ; CHECK-LABEL: test8:
81 ; CHECK:       # BB#0:
82 ; CHECK-NEXT:    retq
83   %t1 = fmul float %a, 0.0
84   %t2 = fadd float %a, %t1
85   ret float %t2
86 }
87
88 define float @test9(float %a) {
89 ; CHECK-LABEL: test9:
90 ; CHECK:       # BB#0:
91 ; CHECK-NEXT:    retq
92   %t1 = fmul float 0.0, %a
93   %t2 = fadd float %t1, %a
94   ret float %t2
95 }
96
97 define float @test10(float %a) {
98 ; CHECK-LABEL: test10:
99 ; CHECK:       # BB#0:
100 ; CHECK-NEXT:    vxorps %xmm0, %xmm0, %xmm0
101 ; CHECK-NEXT:    retq
102   %t1 = fsub float -0.0, %a
103   %t2 = fadd float %a, %t1
104   ret float %t2
105 }
106
107 define float @test11(float %a) {
108 ; CHECK-LABEL: test11:
109 ; CHECK:       # BB#0:
110 ; CHECK-NEXT:    vxorps %xmm0, %xmm0, %xmm0
111 ; CHECK-NEXT:    retq
112   %t1 = fsub float -0.0, %a
113   %t2 = fadd float %a, %t1
114   ret float %t2
115 }
116