1; This tries to be a comprehensive test of f32 and f64 arith operations.
2; The CHECK lines are only checking for basic instruction patterns
3; that should be present regardless of the optimization level, so
4; there are no special OPTM1 match lines.
5
6; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
7; RUN:   --target x8632 -i %s --args -O2 \
8; RUN:   | %if --need=target_X8632 --command FileCheck %s
9; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
10; RUN:   --target x8632 -i %s --args -Om1 \
11; RUN:   | %if --need=target_X8632 --command FileCheck %s
12
13; RUN: %if --need=target_ARM32 \
14; RUN:   --command %p2i --filetype=obj --disassemble --target arm32 \
15; RUN:   -i %s --args -O2 \
16; RUN:   | %if --need=target_ARM32 \
17; RUN:   --command FileCheck --check-prefix ARM32 %s
18; RUN: %if --need=target_ARM32 \
19; RUN:   --command %p2i --filetype=obj --disassemble --target arm32 \
20; RUN:   -i %s --args -Om1 \
21; RUN:   | %if --need=target_ARM32 \
22; RUN:   --command FileCheck --check-prefix ARM32 %s
23
24; RUN: %if --need=target_MIPS32 --need=allow_dump \
25; RUN:   --command %p2i --filetype=asm --assemble --disassemble --target \
26; RUN:   mips32 -i %s --args -O2 \
27; RUN:   | %if --need=target_MIPS32 --need=allow_dump \
28; RUN:   --command FileCheck --check-prefix MIPS32 %s
29; RUN: %if --need=target_MIPS32 --need=allow_dump \
30; RUN:   --command %p2i --filetype=asm --assemble --disassemble --target \
31; RUN:   mips32 -i %s --args -Om1 \
32; RUN:   | %if --need=target_MIPS32 --need=allow_dump \
33; RUN:   --command FileCheck --check-prefix MIPS32 %s
34
35define internal float @addFloat(float %a, float %b) {
36entry:
37  %add = fadd float %a, %b
38  ret float %add
39}
40; CHECK-LABEL: addFloat
41; CHECK: addss
42; CHECK: fld
43; ARM32-LABEL: addFloat
44; ARM32: vadd.f32 s{{[0-9]+}}, s
45; MIPS32-LABEL: addFloat
46; MIPS32: add.s
47
48define internal double @addDouble(double %a, double %b) {
49entry:
50  %add = fadd double %a, %b
51  ret double %add
52}
53; CHECK-LABEL: addDouble
54; CHECK: addsd
55; CHECK: fld
56; ARM32-LABEL: addDouble
57; ARM32: vadd.f64 d{{[0-9]+}}, d
58; MIPS32-LABEL: addDouble
59; MIPS32: add.d
60
61define internal float @subFloat(float %a, float %b) {
62entry:
63  %sub = fsub float %a, %b
64  ret float %sub
65}
66; CHECK-LABEL: subFloat
67; CHECK: subss
68; CHECK: fld
69; ARM32-LABEL: subFloat
70; ARM32: vsub.f32 s{{[0-9]+}}, s
71; MIPS32-LABEL: subFloat
72; MIPS32: sub.s
73
74define internal double @subDouble(double %a, double %b) {
75entry:
76  %sub = fsub double %a, %b
77  ret double %sub
78}
79; CHECK-LABEL: subDouble
80; CHECK: subsd
81; CHECK: fld
82; ARM32-LABEL: subDouble
83; ARM32: vsub.f64 d{{[0-9]+}}, d
84; MIPS32-LABEL: subDouble
85; MIPS32: sub.d
86
87define internal float @mulFloat(float %a, float %b) {
88entry:
89  %mul = fmul float %a, %b
90  ret float %mul
91}
92; CHECK-LABEL: mulFloat
93; CHECK: mulss
94; CHECK: fld
95; ARM32-LABEL: mulFloat
96; ARM32: vmul.f32 s{{[0-9]+}}, s
97; MIPS32-LABEL: mulFloat
98; MIPS32: mul.s
99
100define internal double @mulDouble(double %a, double %b) {
101entry:
102  %mul = fmul double %a, %b
103  ret double %mul
104}
105; CHECK-LABEL: mulDouble
106; CHECK: mulsd
107; CHECK: fld
108; ARM32-LABEL: mulDouble
109; ARM32: vmul.f64 d{{[0-9]+}}, d
110; MIPS32-LABEL: mulDouble
111; MIPS32: mul.d
112
113define internal float @divFloat(float %a, float %b) {
114entry:
115  %div = fdiv float %a, %b
116  ret float %div
117}
118; CHECK-LABEL: divFloat
119; CHECK: divss
120; CHECK: fld
121; ARM32-LABEL: divFloat
122; ARM32: vdiv.f32 s{{[0-9]+}}, s
123; MIPS32-LABEL: divFloat
124; MIPS32: div.s
125
126define internal double @divDouble(double %a, double %b) {
127entry:
128  %div = fdiv double %a, %b
129  ret double %div
130}
131; CHECK-LABEL: divDouble
132; CHECK: divsd
133; CHECK: fld
134; ARM32-LABEL: divDouble
135; ARM32: vdiv.f64 d{{[0-9]+}}, d
136; MIPS32-LABEL: divDouble
137; MIPS32: div.d
138
139define internal float @remFloat(float %a, float %b) {
140entry:
141  %div = frem float %a, %b
142  ret float %div
143}
144; CHECK-LABEL: remFloat
145; CHECK: call {{.*}} R_{{.*}} fmodf
146; ARM32-LABEL: remFloat
147; ARM32: bl {{.*}} fmodf
148; MIPS32-LABEL: remFloat
149; MIPS32: jal {{.*}} fmodf
150
151define internal double @remDouble(double %a, double %b) {
152entry:
153  %div = frem double %a, %b
154  ret double %div
155}
156; CHECK-LABEL: remDouble
157; CHECK: call {{.*}} R_{{.*}} fmod
158; ARM32-LABEL: remDouble
159; ARM32: bl {{.*}} fmod
160; MIPS32-LABEL: remDouble
161; MIPS32: jal {{.*}} fmod
162