Add a few more simple fast-math constant propagations and cancellations.
[oota-llvm.git] / test / CodeGen / X86 / fp-fast.ll
1 ; RUN: llc -march=x86-64 -mattr=-fma4 -mtriple=x86_64-apple-darwin -enable-unsafe-fp-math < %s | FileCheck %s
2
3 ; CHECK: test1
4 define float @test1(float %a) {
5 ; CHECK-NOT: addss
6 ; CHECK: mulss
7 ; CHECK-NOT: addss
8 ; CHECK: ret
9   %t1 = fadd float %a, %a
10   %r = fadd float %t1, %t1
11   ret float %r
12 }
13
14 ; CHECK: test2
15 define float @test2(float %a) {
16 ; CHECK-NOT: addss
17 ; CHECK: mulss
18 ; CHECK-NOT: addss
19 ; CHECK: ret
20   %t1 = fmul float 4.0, %a
21   %t2 = fadd float %a, %a
22   %r = fadd float %t1, %t2
23   ret float %r
24 }
25
26 ; CHECK: test3
27 define float @test3(float %a) {
28 ; CHECK-NOT: addss
29 ; CHECK: xorps
30 ; CHECK-NOT: addss
31 ; CHECK: ret
32   %t1 = fmul float 2.0, %a
33   %t2 = fadd float %a, %a
34   %r = fsub float %t1, %t2
35   ret float %r
36 }
37
38 ; CHECK: test4
39 define float @test4(float %a) {
40 ; CHECK-NOT: fma
41 ; CHECK-NOT mul
42 ; CHECK-NOT: add
43 ; CHECK: ret
44   %t1 = fmul float %a, 0.0
45   %t2 = fadd float %a, %t1
46   ret float %t2
47 }
48
49 ; CHECK: test5
50 define float @test5(float %a) {
51 ; CHECK-NOT: add
52 ; CHECK: vxorps
53 ; CHECK: ret
54   %t1 = fsub float -0.0, %a
55   %t2 = fadd float %a, %t1
56   ret float %t2
57 }