1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 < %s | FileCheck -check-prefix=GCN %s
3; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx1010 < %s | FileCheck -check-prefix=GFX10 %s
4
5define double @v_constained_fsub_f64_fpexcept_strict(double %x, double %y) #0 {
6; GCN-LABEL: v_constained_fsub_f64_fpexcept_strict:
7; GCN:       ; %bb.0:
8; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
9; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
10; GCN-NEXT:    s_setpc_b64 s[30:31]
11;
12; GFX10-LABEL: v_constained_fsub_f64_fpexcept_strict:
13; GFX10:       ; %bb.0:
14; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
15; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
16; GFX10-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
17; GFX10-NEXT:    s_setpc_b64 s[30:31]
18  %val = call double @llvm.experimental.constrained.fsub.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.strict")
19  ret double %val
20}
21
22define double @v_constained_fsub_f64_fpexcept_ignore(double %x, double %y) #0 {
23; GCN-LABEL: v_constained_fsub_f64_fpexcept_ignore:
24; GCN:       ; %bb.0:
25; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
26; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
27; GCN-NEXT:    s_setpc_b64 s[30:31]
28;
29; GFX10-LABEL: v_constained_fsub_f64_fpexcept_ignore:
30; GFX10:       ; %bb.0:
31; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
32; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
33; GFX10-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
34; GFX10-NEXT:    s_setpc_b64 s[30:31]
35  %val = call double @llvm.experimental.constrained.fsub.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.ignore")
36  ret double %val
37}
38
39define double @v_constained_fsub_f64_fpexcept_maytrap(double %x, double %y) #0 {
40; GCN-LABEL: v_constained_fsub_f64_fpexcept_maytrap:
41; GCN:       ; %bb.0:
42; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
43; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
44; GCN-NEXT:    s_setpc_b64 s[30:31]
45;
46; GFX10-LABEL: v_constained_fsub_f64_fpexcept_maytrap:
47; GFX10:       ; %bb.0:
48; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
49; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
50; GFX10-NEXT:    v_add_f64 v[0:1], v[0:1], -v[2:3]
51; GFX10-NEXT:    s_setpc_b64 s[30:31]
52  %val = call double @llvm.experimental.constrained.fsub.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
53  ret double %val
54}
55
56define <2 x double> @v_constained_fsub_v2f64_fpexcept_strict(<2 x double> %x, <2 x double> %y) #0 {
57; GCN-LABEL: v_constained_fsub_v2f64_fpexcept_strict:
58; GCN:       ; %bb.0:
59; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
60; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[4:5]
61; GCN-NEXT:    v_add_f64 v[2:3], v[2:3], -v[6:7]
62; GCN-NEXT:    s_setpc_b64 s[30:31]
63;
64; GFX10-LABEL: v_constained_fsub_v2f64_fpexcept_strict:
65; GFX10:       ; %bb.0:
66; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
67; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
68; GFX10-NEXT:    v_mov_b32_e32 v9, v3
69; GFX10-NEXT:    v_mov_b32_e32 v8, v2
70; GFX10-NEXT:    v_mov_b32_e32 v11, v1
71; GFX10-NEXT:    v_mov_b32_e32 v10, v0
72; GFX10-NEXT:    v_add_f64 v[2:3], v[8:9], -v[6:7]
73; GFX10-NEXT:    v_add_f64 v[0:1], v[10:11], -v[4:5]
74; GFX10-NEXT:    s_setpc_b64 s[30:31]
75  %val = call <2 x double> @llvm.experimental.constrained.fsub.v2f64(<2 x double> %x, <2 x double> %y, metadata !"round.tonearest", metadata !"fpexcept.strict")
76  ret <2 x double> %val
77}
78
79define <2 x double> @v_constained_fsub_v2f64_fpexcept_ignore(<2 x double> %x, <2 x double> %y) #0 {
80; GCN-LABEL: v_constained_fsub_v2f64_fpexcept_ignore:
81; GCN:       ; %bb.0:
82; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
83; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[4:5]
84; GCN-NEXT:    v_add_f64 v[2:3], v[2:3], -v[6:7]
85; GCN-NEXT:    s_setpc_b64 s[30:31]
86;
87; GFX10-LABEL: v_constained_fsub_v2f64_fpexcept_ignore:
88; GFX10:       ; %bb.0:
89; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
90; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
91; GFX10-NEXT:    v_mov_b32_e32 v9, v3
92; GFX10-NEXT:    v_mov_b32_e32 v8, v2
93; GFX10-NEXT:    v_mov_b32_e32 v11, v1
94; GFX10-NEXT:    v_mov_b32_e32 v10, v0
95; GFX10-NEXT:    v_add_f64 v[2:3], v[8:9], -v[6:7]
96; GFX10-NEXT:    v_add_f64 v[0:1], v[10:11], -v[4:5]
97; GFX10-NEXT:    s_setpc_b64 s[30:31]
98  %val = call <2 x double> @llvm.experimental.constrained.fsub.v2f64(<2 x double> %x, <2 x double> %y, metadata !"round.tonearest", metadata !"fpexcept.ignore")
99  ret <2 x double> %val
100}
101
102define <2 x double> @v_constained_fsub_v2f64_fpexcept_maytrap(<2 x double> %x, <2 x double> %y) #0 {
103; GCN-LABEL: v_constained_fsub_v2f64_fpexcept_maytrap:
104; GCN:       ; %bb.0:
105; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
106; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[4:5]
107; GCN-NEXT:    v_add_f64 v[2:3], v[2:3], -v[6:7]
108; GCN-NEXT:    s_setpc_b64 s[30:31]
109;
110; GFX10-LABEL: v_constained_fsub_v2f64_fpexcept_maytrap:
111; GFX10:       ; %bb.0:
112; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
113; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
114; GFX10-NEXT:    v_mov_b32_e32 v9, v3
115; GFX10-NEXT:    v_mov_b32_e32 v8, v2
116; GFX10-NEXT:    v_mov_b32_e32 v11, v1
117; GFX10-NEXT:    v_mov_b32_e32 v10, v0
118; GFX10-NEXT:    v_add_f64 v[2:3], v[8:9], -v[6:7]
119; GFX10-NEXT:    v_add_f64 v[0:1], v[10:11], -v[4:5]
120; GFX10-NEXT:    s_setpc_b64 s[30:31]
121  %val = call <2 x double> @llvm.experimental.constrained.fsub.v2f64(<2 x double> %x, <2 x double> %y, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
122  ret <2 x double> %val
123}
124
125define <3 x double> @v_constained_fsub_v3f64_fpexcept_strict(<3 x double> %x, <3 x double> %y) #0 {
126; GCN-LABEL: v_constained_fsub_v3f64_fpexcept_strict:
127; GCN:       ; %bb.0:
128; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
129; GCN-NEXT:    v_add_f64 v[0:1], v[0:1], -v[6:7]
130; GCN-NEXT:    v_add_f64 v[2:3], v[2:3], -v[8:9]
131; GCN-NEXT:    v_add_f64 v[4:5], v[4:5], -v[10:11]
132; GCN-NEXT:    s_setpc_b64 s[30:31]
133;
134; GFX10-LABEL: v_constained_fsub_v3f64_fpexcept_strict:
135; GFX10:       ; %bb.0:
136; GFX10-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
137; GFX10-NEXT:    s_waitcnt_vscnt null, 0x0
138; GFX10-NEXT:    v_add_f64 v[0:1], v[0:1], -v[6:7]
139; GFX10-NEXT:    v_add_f64 v[2:3], v[2:3], -v[8:9]
140; GFX10-NEXT:    v_add_f64 v[4:5], v[4:5], -v[10:11]
141; GFX10-NEXT:    s_setpc_b64 s[30:31]
142  %val = call <3 x double> @llvm.experimental.constrained.fsub.v3f64(<3 x double> %x, <3 x double> %y, metadata !"round.tonearest", metadata !"fpexcept.strict")
143  ret <3 x double> %val
144}
145
146define amdgpu_ps <2 x float> @s_constained_fsub_f64_fpexcept_strict(double inreg %x, double inreg %y) #0 {
147; GCN-LABEL: s_constained_fsub_f64_fpexcept_strict:
148; GCN:       ; %bb.0:
149; GCN-NEXT:    v_mov_b32_e32 v0, s4
150; GCN-NEXT:    v_mov_b32_e32 v1, s5
151; GCN-NEXT:    v_add_f64 v[0:1], s[2:3], -v[0:1]
152; GCN-NEXT:    ; return to shader part epilog
153;
154; GFX10-LABEL: s_constained_fsub_f64_fpexcept_strict:
155; GFX10:       ; %bb.0:
156; GFX10-NEXT:    v_add_f64 v[0:1], s[2:3], -s[4:5]
157; GFX10-NEXT:    ; return to shader part epilog
158  %val = call double @llvm.experimental.constrained.fsub.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.strict")
159  %cast = bitcast double %val to <2 x float>
160  ret <2 x float> %cast
161}
162
163declare double @llvm.experimental.constrained.fsub.f64(double, double, metadata, metadata) #1
164declare <2 x double> @llvm.experimental.constrained.fsub.v2f64(<2 x double>, <2 x double>, metadata, metadata) #1
165declare <3 x double> @llvm.experimental.constrained.fsub.v3f64(<3 x double>, <3 x double>, metadata, metadata) #1
166
167attributes #0 = { strictfp }
168attributes #1 = { inaccessiblememonly nounwind willreturn }
169