blob: eb29b89018d114d1d975a192dadec99bd41d1c69 [file] [log] [blame]
Matt Arsenault32e6bfa2017-01-30 17:57:28 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
2
3; Test fcmp pred (fneg x), c -> fcmp (swapped pred) x, -c combine.
4
5; GCN-LABEL: {{^}}multi_use_fneg_src:
6; GCN: buffer_load_dword [[A:v[0-9]+]]
7; GCN: buffer_load_dword [[B:v[0-9]+]]
8; GCN: buffer_load_dword [[C:v[0-9]+]]
9
10; GCN: v_mul_f32_e32 [[MUL:v[0-9]+]], [[B]], [[A]]
11; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[MUL]]
12; GCN: buffer_store_dword [[MUL]]
13define void @multi_use_fneg_src() #0 {
14 %a = load volatile float, float addrspace(1)* undef
15 %b = load volatile float, float addrspace(1)* undef
16 %x = load volatile i32, i32 addrspace(1)* undef
17 %y = load volatile i32, i32 addrspace(1)* undef
18
19 %mul = fmul float %a, %b
20 %neg.mul = fsub float -0.0, %mul
21 %cmp = fcmp oeq float %neg.mul, 4.0
22 %select = select i1 %cmp, i32 %x, i32 %y
23 store volatile i32 %select, i32 addrspace(1)* undef
24 store volatile float %mul, float addrspace(1)* undef
25 ret void
26}
27
28; GCN-LABEL: {{^}}multi_foldable_use_fneg_src:
29; GCN: buffer_load_dword [[A:v[0-9]+]]
30; GCN: buffer_load_dword [[B:v[0-9]+]]
31; GCN: buffer_load_dword [[C:v[0-9]+]]
32
33; GCN: v_mul_f32_e32 [[MUL:v[0-9]+]], [[B]], [[A]]
34; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[A]]
35; GCN: v_mul_f32_e64 [[USE1:v[0-9]+]], [[MUL]], -[[MUL]]
36define void @multi_foldable_use_fneg_src() #0 {
37 %a = load volatile float, float addrspace(1)* undef
38 %b = load volatile float, float addrspace(1)* undef
39 %x = load volatile i32, i32 addrspace(1)* undef
40 %y = load volatile i32, i32 addrspace(1)* undef
41
42 %mul = fmul float %a, %b
43 %neg.mul = fsub float -0.0, %mul
44 %use1 = fmul float %mul, %neg.mul
45 %cmp = fcmp oeq float %neg.mul, 4.0
46 %select = select i1 %cmp, i32 %x, i32 %y
47
48 store volatile i32 %select, i32 addrspace(1)* undef
49 store volatile float %use1, float addrspace(1)* undef
50 ret void
51}
52
53; GCN-LABEL: {{^}}multi_use_fneg:
54; GCN: buffer_load_dword [[A:v[0-9]+]]
55; GCN: buffer_load_dword [[B:v[0-9]+]]
56; GCN: buffer_load_dword [[C:v[0-9]+]]
57
58; GCN: v_mul_f32_e32 [[MUL:v[0-9]+]], [[B]], [[A]]
59; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[MUL]]
60; GCN: buffer_store_dword [[MUL]]
61define void @multi_use_fneg() #0 {
62 %a = load volatile float, float addrspace(1)* undef
63 %b = load volatile float, float addrspace(1)* undef
64 %x = load volatile i32, i32 addrspace(1)* undef
65 %y = load volatile i32, i32 addrspace(1)* undef
66
67 %mul = fmul float %a, %b
68 %neg.mul = fsub float -0.0, %mul
69 %cmp = fcmp oeq float %neg.mul, 4.0
70 %select = select i1 %cmp, i32 %x, i32 %y
71 store volatile i32 %select, i32 addrspace(1)* undef
72 store volatile float %neg.mul, float addrspace(1)* undef
73 ret void
74}
75
76; GCN-LABEL: {{^}}multi_foldable_use_fneg:
77; GCN: buffer_load_dword [[A:v[0-9]+]]
78; GCN: buffer_load_dword [[B:v[0-9]+]]
79
80; GCN: v_mul_f32_e32 [[MUL0:v[0-9]+]], [[B]], [[A]]
81; GCN: v_cmp_eq_f32_e32 vcc, -4.0, [[MUL0]]
82; GCN: v_mul_f32_e64 [[MUL1:v[0-9]+]], -[[MUL0]], [[MUL0]]
83; GCN: buffer_store_dword [[MUL1]]
84define void @multi_foldable_use_fneg() #0 {
85 %a = load volatile float, float addrspace(1)* undef
86 %b = load volatile float, float addrspace(1)* undef
87 %x = load volatile i32, i32 addrspace(1)* undef
88 %y = load volatile i32, i32 addrspace(1)* undef
89 %z = load volatile i32, i32 addrspace(1)* undef
90
91 %mul = fmul float %a, %b
92 %neg.mul = fsub float -0.0, %mul
93 %cmp = fcmp oeq float %neg.mul, 4.0
94 %select = select i1 %cmp, i32 %x, i32 %y
95 %use1 = fmul float %neg.mul, %mul
96 store volatile i32 %select, i32 addrspace(1)* undef
97 store volatile float %use1, float addrspace(1)* undef
98 ret void
99}
100
101; GCN-LABEL: {{^}}test_setcc_fneg_oeq_posk_f32:
102; GCN: v_cmp_eq_f32_e32 vcc, -4.0, v{{[0-9]+}}
103define void @test_setcc_fneg_oeq_posk_f32() #0 {
104 %a = load volatile float, float addrspace(1)* undef
105 %x = load volatile i32, i32 addrspace(1)* undef
106 %y = load volatile i32, i32 addrspace(1)* undef
107 %neg.a = fsub float -0.0, %a
108 %cmp = fcmp oeq float %neg.a, 4.0
109 %select = select i1 %cmp, i32 %x, i32 %y
110 store volatile i32 %select, i32 addrspace(1)* undef
111 ret void
112}
113
114; GCN-LABEL: {{^}}test_setcc_fneg_ogt_posk_f32:
115; GCN: v_cmp_gt_f32_e32 vcc, -4.0, v{{[0-9]+}}
116define void @test_setcc_fneg_ogt_posk_f32() #0 {
117 %a = load volatile float, float addrspace(1)* undef
118 %x = load volatile i32, i32 addrspace(1)* undef
119 %y = load volatile i32, i32 addrspace(1)* undef
120 %neg.a = fsub float -0.0, %a
121 %cmp = fcmp ogt float %neg.a, 4.0
122 %select = select i1 %cmp, i32 %x, i32 %y
123 store volatile i32 %select, i32 addrspace(1)* undef
124 ret void
125}
126
127; GCN-LABEL: {{^}}test_setcc_fneg_oge_posk_f32:
128; GCN: v_cmp_ge_f32_e32 vcc, -4.0, v{{[0-9]+}}
129define void @test_setcc_fneg_oge_posk_f32() #0 {
130 %a = load volatile float, float addrspace(1)* undef
131 %x = load volatile i32, i32 addrspace(1)* undef
132 %y = load volatile i32, i32 addrspace(1)* undef
133 %neg.a = fsub float -0.0, %a
134 %cmp = fcmp oge float %neg.a, 4.0
135 %select = select i1 %cmp, i32 %x, i32 %y
136 store volatile i32 %select, i32 addrspace(1)* undef
137 ret void
138}
139
140; GCN-LABEL: {{^}}test_setcc_fneg_olt_posk_f32:
141; GCN: v_cmp_lt_f32_e32 vcc, -4.0, v{{[0-9]+}}
142define void @test_setcc_fneg_olt_posk_f32() #0 {
143 %a = load volatile float, float addrspace(1)* undef
144 %x = load volatile i32, i32 addrspace(1)* undef
145 %y = load volatile i32, i32 addrspace(1)* undef
146 %neg.a = fsub float -0.0, %a
147 %cmp = fcmp olt float %neg.a, 4.0
148 %select = select i1 %cmp, i32 %x, i32 %y
149 store volatile i32 %select, i32 addrspace(1)* undef
150 ret void
151}
152
153; GCN-LABEL: {{^}}test_setcc_fneg_ole_posk_f32:
154; GCN: v_cmp_le_f32_e32 vcc, -4.0, v{{[0-9]+}}
155define void @test_setcc_fneg_ole_posk_f32() #0 {
156 %a = load volatile float, float addrspace(1)* undef
157 %x = load volatile i32, i32 addrspace(1)* undef
158 %y = load volatile i32, i32 addrspace(1)* undef
159 %neg.a = fsub float -0.0, %a
160 %cmp = fcmp ole float %neg.a, 4.0
161 %select = select i1 %cmp, i32 %x, i32 %y
162 store volatile i32 %select, i32 addrspace(1)* undef
163 ret void
164}
165
166; GCN-LABEL: {{^}}test_setcc_fneg_one_posk_f32:
167; GCN: v_cmp_lg_f32_e32 vcc, -4.0, v{{[0-9]+}}
168define void @test_setcc_fneg_one_posk_f32() #0 {
169 %a = load volatile float, float addrspace(1)* undef
170 %x = load volatile i32, i32 addrspace(1)* undef
171 %y = load volatile i32, i32 addrspace(1)* undef
172 %neg.a = fsub float -0.0, %a
173 %cmp = fcmp one float %neg.a, 4.0
174 %select = select i1 %cmp, i32 %x, i32 %y
175 store volatile i32 %select, i32 addrspace(1)* undef
176 ret void
177}
178
179; GCN-LABEL: {{^}}test_setcc_fneg_ueq_posk_f32:
180; GCN: v_cmp_nlg_f32_e32 vcc, -4.0, v{{[0-9]+}}
181define void @test_setcc_fneg_ueq_posk_f32() #0 {
182 %a = load volatile float, float addrspace(1)* undef
183 %x = load volatile i32, i32 addrspace(1)* undef
184 %y = load volatile i32, i32 addrspace(1)* undef
185 %neg.a = fsub float -0.0, %a
186 %cmp = fcmp ueq float %neg.a, 4.0
187 %select = select i1 %cmp, i32 %x, i32 %y
188 store volatile i32 %select, i32 addrspace(1)* undef
189 ret void
190}
191
192; GCN-LABEL: {{^}}test_setcc_fneg_ugt_posk_f32:
193; GCN: v_cmp_nle_f32_e32 vcc, -4.0, v{{[0-9]+}}
194define void @test_setcc_fneg_ugt_posk_f32() #0 {
195 %a = load volatile float, float addrspace(1)* undef
196 %x = load volatile i32, i32 addrspace(1)* undef
197 %y = load volatile i32, i32 addrspace(1)* undef
198 %neg.a = fsub float -0.0, %a
199 %cmp = fcmp ugt float %neg.a, 4.0
200 %select = select i1 %cmp, i32 %x, i32 %y
201 store volatile i32 %select, i32 addrspace(1)* undef
202 ret void
203}
204
205; GCN-LABEL: {{^}}test_setcc_fneg_uge_posk_f32:
206; GCN: v_cmp_nlt_f32_e32 vcc, -4.0, v{{[0-9]+}}
207define void @test_setcc_fneg_uge_posk_f32() #0 {
208 %a = load volatile float, float addrspace(1)* undef
209 %x = load volatile i32, i32 addrspace(1)* undef
210 %y = load volatile i32, i32 addrspace(1)* undef
211 %neg.a = fsub float -0.0, %a
212 %cmp = fcmp uge float %neg.a, 4.0
213 %select = select i1 %cmp, i32 %x, i32 %y
214 store volatile i32 %select, i32 addrspace(1)* undef
215 ret void
216}
217
218; GCN-LABEL: {{^}}test_setcc_fneg_ult_posk_f32:
219; GCN: v_cmp_nge_f32_e32 vcc, -4.0, v{{[0-9]+}}
220define void @test_setcc_fneg_ult_posk_f32() #0 {
221 %a = load volatile float, float addrspace(1)* undef
222 %x = load volatile i32, i32 addrspace(1)* undef
223 %y = load volatile i32, i32 addrspace(1)* undef
224 %neg.a = fsub float -0.0, %a
225 %cmp = fcmp ult float %neg.a, 4.0
226 %select = select i1 %cmp, i32 %x, i32 %y
227 store volatile i32 %select, i32 addrspace(1)* undef
228 ret void
229}
230
231; GCN-LABEL: {{^}}test_setcc_fneg_ule_posk_f32:
232; GCN: v_cmp_ngt_f32_e32 vcc, -4.0, v{{[0-9]+}}
233define void @test_setcc_fneg_ule_posk_f32() #0 {
234 %a = load volatile float, float addrspace(1)* undef
235 %x = load volatile i32, i32 addrspace(1)* undef
236 %y = load volatile i32, i32 addrspace(1)* undef
237 %neg.a = fsub float -0.0, %a
238 %cmp = fcmp ule float %neg.a, 4.0
239 %select = select i1 %cmp, i32 %x, i32 %y
240 store volatile i32 %select, i32 addrspace(1)* undef
241 ret void
242}
243
244; GCN-LABEL: {{^}}test_setcc_fneg_une_posk_f32:
245; GCN: v_cmp_neq_f32_e32 vcc, -4.0, v{{[0-9]+}}
246define void @test_setcc_fneg_une_posk_f32() #0 {
247 %a = load volatile float, float addrspace(1)* undef
248 %x = load volatile i32, i32 addrspace(1)* undef
249 %y = load volatile i32, i32 addrspace(1)* undef
250 %neg.a = fsub float -0.0, %a
251 %cmp = fcmp une float %neg.a, 4.0
252 %select = select i1 %cmp, i32 %x, i32 %y
253 store volatile i32 %select, i32 addrspace(1)* undef
254 ret void
255}
256
257attributes #0 = { nounwind }