Fix a bug in codegenprep where it was losing track of values OptimizeMemoryInst
[oota-llvm.git] / test / CodeGen / AArch64 / fp-dp3.ll
1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -fp-contract=fast | FileCheck %s
2
3 declare float @llvm.fma.f32(float, float, float)
4 declare double @llvm.fma.f64(double, double, double)
5
6 define float @test_fmadd(float %a, float %b, float %c) {
7 ; CHECK: test_fmadd:
8   %val = call float @llvm.fma.f32(float %a, float %b, float %c)
9 ; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
10   ret float %val
11 }
12
13 define float @test_fmsub(float %a, float %b, float %c) {
14 ; CHECK: test_fmsub:
15   %nega = fsub float -0.0, %a
16   %val = call float @llvm.fma.f32(float %nega, float %b, float %c)
17 ; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
18   ret float %val
19 }
20
21 define float @test_fnmadd(float %a, float %b, float %c) {
22 ; CHECK: test_fnmadd:
23   %negc = fsub float -0.0, %c
24   %val = call float @llvm.fma.f32(float %a, float %b, float %negc)
25 ; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
26   ret float %val
27 }
28
29 define float @test_fnmsub(float %a, float %b, float %c) {
30 ; CHECK: test_fnmsub:
31   %nega = fsub float -0.0, %a
32   %negc = fsub float -0.0, %c
33   %val = call float @llvm.fma.f32(float %nega, float %b, float %negc)
34 ; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
35   ret float %val
36 }
37
38 define double @testd_fmadd(double %a, double %b, double %c) {
39 ; CHECK: testd_fmadd:
40   %val = call double @llvm.fma.f64(double %a, double %b, double %c)
41 ; CHECK: fmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
42   ret double %val
43 }
44
45 define double @testd_fmsub(double %a, double %b, double %c) {
46 ; CHECK: testd_fmsub:
47   %nega = fsub double -0.0, %a
48   %val = call double @llvm.fma.f64(double %nega, double %b, double %c)
49 ; CHECK: fmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
50   ret double %val
51 }
52
53 define double @testd_fnmadd(double %a, double %b, double %c) {
54 ; CHECK: testd_fnmadd:
55   %negc = fsub double -0.0, %c
56   %val = call double @llvm.fma.f64(double %a, double %b, double %negc)
57 ; CHECK: fnmadd {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
58   ret double %val
59 }
60
61 define double @testd_fnmsub(double %a, double %b, double %c) {
62 ; CHECK: testd_fnmsub:
63   %nega = fsub double -0.0, %a
64   %negc = fsub double -0.0, %c
65   %val = call double @llvm.fma.f64(double %nega, double %b, double %negc)
66 ; CHECK: fnmsub {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}}
67   ret double %val
68 }
69
70 define float @test_fmadd_unfused(float %a, float %b, float %c) {
71 ; CHECK: test_fmadd_unfused:
72   %prod = fmul float %b, %c
73   %sum = fadd float %a, %prod
74 ; CHECK: fmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
75   ret float %sum
76 }
77
78 define float @test_fmsub_unfused(float %a, float %b, float %c) {
79 ; CHECK: test_fmsub_unfused:
80   %prod = fmul float %b, %c
81   %diff = fsub float %a, %prod
82 ; CHECK: fmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
83   ret float %diff
84 }
85
86 define float @test_fnmadd_unfused(float %a, float %b, float %c) {
87 ; CHECK: test_fnmadd_unfused:
88   %nega = fsub float -0.0, %a
89   %prod = fmul float %b, %c
90   %sum = fadd float %nega, %prod
91 ; CHECK: fnmadd {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
92   ret float %sum
93 }
94
95 define float @test_fnmsub_unfused(float %a, float %b, float %c) {
96 ; CHECK: test_fnmsub_unfused:
97   %nega = fsub float -0.0, %a
98   %prod = fmul float %b, %c
99   %diff = fsub float %nega, %prod
100 ; CHECK: fnmsub {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
101   ret float %diff
102 }