llvm.org GIT mirror llvm / 6bc72be
[RISCV] Add seto pattern expansion Adds a `seto` pattern expansion. Without it the lowerings of `fcmp one` and `fcmp ord` would be inefficient due to an unoptimized double negation. Differential Revision: https://reviews.llvm.org/D59699 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357378 91177308-0d34-0410-b5e6-96231b3b80d8 Luis Marques 1 year, 8 months ago
9 changed file(s) with 11 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
136136 setOperationAction(ISD::CTPOP, XLenVT, Expand);
137137
138138 ISD::CondCode FPCCToExtend[] = {
139 ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETO, ISD::SETUEQ,
140 ISD::SETUGT, ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE,
141 ISD::SETGT, ISD::SETGE, ISD::SETNE};
139 ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETUEQ, ISD::SETUGT,
140 ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE, ISD::SETGT,
141 ISD::SETGE, ISD::SETNE};
142142
143143 ISD::NodeType FPOpToExtend[] = {
144144 ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOW, ISD::FREM};
269269 // handled by a RISC-V instruction and aren't expanded in the SelectionDAG
270270 // Legalizer.
271271
272 def : Pat<(seto FPR64:$rs1, FPR64:$rs2),
273 (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
274 (FEQ_D FPR64:$rs2, FPR64:$rs2))>;
275
272276 def : Pat<(setuo FPR64:$rs1, FPR64:$rs2),
273277 (SLTIU (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
274278 (FEQ_D FPR64:$rs2, FPR64:$rs2)),
323323 // handled by a RISC-V instruction and aren't expanded in the SelectionDAG
324324 // Legalizer.
325325
326 def : Pat<(seto FPR32:$rs1, FPR32:$rs2),
327 (AND (FEQ_S FPR32:$rs1, FPR32:$rs1),
328 (FEQ_S FPR32:$rs2, FPR32:$rs2))>;
329
326330 def : Pat<(setuo FPR32:$rs1, FPR32:$rs2),
327331 (SLTIU (AND (FEQ_S FPR32:$rs1, FPR32:$rs1),
328332 (FEQ_S FPR32:$rs2, FPR32:$rs2)),
321321 ; RV32IFD-NEXT: and a0, a1, a0
322322 ; RV32IFD-NEXT: feq.d a1, ft0, ft1
323323 ; RV32IFD-NEXT: not a1, a1
324 ; RV32IFD-NEXT: seqz a0, a0
325 ; RV32IFD-NEXT: xori a0, a0, 1
326324 ; RV32IFD-NEXT: and a0, a1, a0
327325 ; RV32IFD-NEXT: bnez a0, .LBB7_2
328326 ; RV32IFD-NEXT: # %bb.1: # %if.else
343341 ; RV64IFD-NEXT: and a0, a1, a0
344342 ; RV64IFD-NEXT: feq.d a1, ft0, ft1
345343 ; RV64IFD-NEXT: not a1, a1
346 ; RV64IFD-NEXT: seqz a0, a0
347 ; RV64IFD-NEXT: xori a0, a0, 1
348344 ; RV64IFD-NEXT: and a0, a1, a0
349345 ; RV64IFD-NEXT: bnez a0, .LBB7_2
350346 ; RV64IFD-NEXT: # %bb.1: # %if.else
376372 ; RV32IFD-NEXT: feq.d a0, ft1, ft1
377373 ; RV32IFD-NEXT: feq.d a1, ft0, ft0
378374 ; RV32IFD-NEXT: and a0, a1, a0
379 ; RV32IFD-NEXT: seqz a0, a0
380 ; RV32IFD-NEXT: xori a0, a0, 1
381375 ; RV32IFD-NEXT: bnez a0, .LBB8_2
382376 ; RV32IFD-NEXT: # %bb.1: # %if.else
383377 ; RV32IFD-NEXT: lw ra, 12(sp)
395389 ; RV64IFD-NEXT: fmv.d.x ft0, a0
396390 ; RV64IFD-NEXT: feq.d a0, ft0, ft0
397391 ; RV64IFD-NEXT: and a0, a0, a1
398 ; RV64IFD-NEXT: seqz a0, a0
399 ; RV64IFD-NEXT: xori a0, a0, 1
400392 ; RV64IFD-NEXT: bnez a0, .LBB8_2
401393 ; RV64IFD-NEXT: # %bb.1: # %if.else
402394 ; RV64IFD-NEXT: ld ra, 8(sp)
158158 ; RV32IFD-NEXT: and a0, a1, a0
159159 ; RV32IFD-NEXT: feq.d a1, ft0, ft1
160160 ; RV32IFD-NEXT: not a1, a1
161 ; RV32IFD-NEXT: seqz a0, a0
162 ; RV32IFD-NEXT: xori a0, a0, 1
163161 ; RV32IFD-NEXT: and a0, a1, a0
164162 ; RV32IFD-NEXT: addi sp, sp, 16
165163 ; RV32IFD-NEXT: ret
173171 ; RV64IFD-NEXT: and a0, a1, a0
174172 ; RV64IFD-NEXT: feq.d a1, ft0, ft1
175173 ; RV64IFD-NEXT: not a1, a1
176 ; RV64IFD-NEXT: seqz a0, a0
177 ; RV64IFD-NEXT: xori a0, a0, 1
178174 ; RV64IFD-NEXT: and a0, a1, a0
179175 ; RV64IFD-NEXT: ret
180176 %1 = fcmp one double %a, %b
195191 ; RV32IFD-NEXT: feq.d a0, ft1, ft1
196192 ; RV32IFD-NEXT: feq.d a1, ft0, ft0
197193 ; RV32IFD-NEXT: and a0, a1, a0
198 ; RV32IFD-NEXT: seqz a0, a0
199 ; RV32IFD-NEXT: xori a0, a0, 1
200194 ; RV32IFD-NEXT: addi sp, sp, 16
201195 ; RV32IFD-NEXT: ret
202196 ;
207201 ; RV64IFD-NEXT: fmv.d.x ft0, a0
208202 ; RV64IFD-NEXT: feq.d a0, ft0, ft0
209203 ; RV64IFD-NEXT: and a0, a0, a1
210 ; RV64IFD-NEXT: seqz a0, a0
211 ; RV64IFD-NEXT: xori a0, a0, 1
212204 ; RV64IFD-NEXT: ret
213205 %1 = fcmp ord double %a, %b
214206 %2 = zext i1 %1 to i32
220220 ; RV32IFD-NEXT: and a0, a1, a0
221221 ; RV32IFD-NEXT: feq.d a1, ft0, ft1
222222 ; RV32IFD-NEXT: not a1, a1
223 ; RV32IFD-NEXT: seqz a0, a0
224 ; RV32IFD-NEXT: xori a0, a0, 1
225223 ; RV32IFD-NEXT: and a0, a1, a0
226224 ; RV32IFD-NEXT: bnez a0, .LBB6_2
227225 ; RV32IFD-NEXT: # %bb.1:
242240 ; RV64IFD-NEXT: and a0, a1, a0
243241 ; RV64IFD-NEXT: feq.d a1, ft0, ft1
244242 ; RV64IFD-NEXT: not a1, a1
245 ; RV64IFD-NEXT: seqz a0, a0
246 ; RV64IFD-NEXT: xori a0, a0, 1
247243 ; RV64IFD-NEXT: and a0, a1, a0
248244 ; RV64IFD-NEXT: bnez a0, .LBB6_2
249245 ; RV64IFD-NEXT: # %bb.1:
269265 ; RV32IFD-NEXT: feq.d a0, ft1, ft1
270266 ; RV32IFD-NEXT: feq.d a1, ft0, ft0
271267 ; RV32IFD-NEXT: and a0, a1, a0
272 ; RV32IFD-NEXT: seqz a0, a0
273 ; RV32IFD-NEXT: xori a0, a0, 1
274268 ; RV32IFD-NEXT: bnez a0, .LBB7_2
275269 ; RV32IFD-NEXT: # %bb.1:
276270 ; RV32IFD-NEXT: fmv.d ft0, ft1
288282 ; RV64IFD-NEXT: feq.d a0, ft1, ft1
289283 ; RV64IFD-NEXT: feq.d a1, ft0, ft0
290284 ; RV64IFD-NEXT: and a0, a1, a0
291 ; RV64IFD-NEXT: seqz a0, a0
292 ; RV64IFD-NEXT: xori a0, a0, 1
293285 ; RV64IFD-NEXT: bnez a0, .LBB7_2
294286 ; RV64IFD-NEXT: # %bb.1:
295287 ; RV64IFD-NEXT: fmv.d ft0, ft1
294294 ; RV32IF-NEXT: and a0, a1, a0
295295 ; RV32IF-NEXT: feq.s a1, ft0, ft1
296296 ; RV32IF-NEXT: not a1, a1
297 ; RV32IF-NEXT: seqz a0, a0
298 ; RV32IF-NEXT: xori a0, a0, 1
299297 ; RV32IF-NEXT: and a0, a1, a0
300298 ; RV32IF-NEXT: bnez a0, .LBB7_2
301299 ; RV32IF-NEXT: # %bb.1: # %if.else
316314 ; RV64IF-NEXT: and a0, a1, a0
317315 ; RV64IF-NEXT: feq.s a1, ft0, ft1
318316 ; RV64IF-NEXT: not a1, a1
319 ; RV64IF-NEXT: seqz a0, a0
320 ; RV64IF-NEXT: xori a0, a0, 1
321317 ; RV64IF-NEXT: and a0, a1, a0
322318 ; RV64IF-NEXT: bnez a0, .LBB7_2
323319 ; RV64IF-NEXT: # %bb.1: # %if.else
345341 ; RV32IF-NEXT: fmv.w.x ft0, a0
346342 ; RV32IF-NEXT: feq.s a0, ft0, ft0
347343 ; RV32IF-NEXT: and a0, a0, a1
348 ; RV32IF-NEXT: seqz a0, a0
349 ; RV32IF-NEXT: xori a0, a0, 1
350344 ; RV32IF-NEXT: bnez a0, .LBB8_2
351345 ; RV32IF-NEXT: # %bb.1: # %if.else
352346 ; RV32IF-NEXT: lw ra, 12(sp)
364358 ; RV64IF-NEXT: fmv.w.x ft0, a0
365359 ; RV64IF-NEXT: feq.s a0, ft0, ft0
366360 ; RV64IF-NEXT: and a0, a0, a1
367 ; RV64IF-NEXT: seqz a0, a0
368 ; RV64IF-NEXT: xori a0, a0, 1
369361 ; RV64IF-NEXT: bnez a0, .LBB8_2
370362 ; RV64IF-NEXT: # %bb.1: # %if.else
371363 ; RV64IF-NEXT: ld ra, 8(sp)
123123 ; RV32IF-NEXT: and a0, a1, a0
124124 ; RV32IF-NEXT: feq.s a1, ft0, ft1
125125 ; RV32IF-NEXT: not a1, a1
126 ; RV32IF-NEXT: seqz a0, a0
127 ; RV32IF-NEXT: xori a0, a0, 1
128126 ; RV32IF-NEXT: and a0, a1, a0
129127 ; RV32IF-NEXT: ret
130128 ;
137135 ; RV64IF-NEXT: and a0, a1, a0
138136 ; RV64IF-NEXT: feq.s a1, ft0, ft1
139137 ; RV64IF-NEXT: not a1, a1
140 ; RV64IF-NEXT: seqz a0, a0
141 ; RV64IF-NEXT: xori a0, a0, 1
142138 ; RV64IF-NEXT: and a0, a1, a0
143139 ; RV64IF-NEXT: ret
144140 %1 = fcmp one float %a, %b
154150 ; RV32IF-NEXT: fmv.w.x ft0, a0
155151 ; RV32IF-NEXT: feq.s a0, ft0, ft0
156152 ; RV32IF-NEXT: and a0, a0, a1
157 ; RV32IF-NEXT: seqz a0, a0
158 ; RV32IF-NEXT: xori a0, a0, 1
159153 ; RV32IF-NEXT: ret
160154 ;
161155 ; RV64IF-LABEL: fcmp_ord:
165159 ; RV64IF-NEXT: fmv.w.x ft0, a0
166160 ; RV64IF-NEXT: feq.s a0, ft0, ft0
167161 ; RV64IF-NEXT: and a0, a0, a1
168 ; RV64IF-NEXT: seqz a0, a0
169 ; RV64IF-NEXT: xori a0, a0, 1
170162 ; RV64IF-NEXT: ret
171163 %1 = fcmp ord float %a, %b
172164 %2 = zext i1 %1 to i32
174174 ; RV32IF-NEXT: and a0, a1, a0
175175 ; RV32IF-NEXT: feq.s a1, ft0, ft1
176176 ; RV32IF-NEXT: not a1, a1
177 ; RV32IF-NEXT: seqz a0, a0
178 ; RV32IF-NEXT: xori a0, a0, 1
179177 ; RV32IF-NEXT: and a0, a1, a0
180178 ; RV32IF-NEXT: bnez a0, .LBB6_2
181179 ; RV32IF-NEXT: # %bb.1:
193191 ; RV64IF-NEXT: and a0, a1, a0
194192 ; RV64IF-NEXT: feq.s a1, ft0, ft1
195193 ; RV64IF-NEXT: not a1, a1
196 ; RV64IF-NEXT: seqz a0, a0
197 ; RV64IF-NEXT: xori a0, a0, 1
198194 ; RV64IF-NEXT: and a0, a1, a0
199195 ; RV64IF-NEXT: bnez a0, .LBB6_2
200196 ; RV64IF-NEXT: # %bb.1:
215211 ; RV32IF-NEXT: feq.s a0, ft1, ft1
216212 ; RV32IF-NEXT: feq.s a1, ft0, ft0
217213 ; RV32IF-NEXT: and a0, a1, a0
218 ; RV32IF-NEXT: seqz a0, a0
219 ; RV32IF-NEXT: xori a0, a0, 1
220214 ; RV32IF-NEXT: bnez a0, .LBB7_2
221215 ; RV32IF-NEXT: # %bb.1:
222216 ; RV32IF-NEXT: fmv.s ft0, ft1
231225 ; RV64IF-NEXT: feq.s a0, ft1, ft1
232226 ; RV64IF-NEXT: feq.s a1, ft0, ft0
233227 ; RV64IF-NEXT: and a0, a1, a0
234 ; RV64IF-NEXT: seqz a0, a0
235 ; RV64IF-NEXT: xori a0, a0, 1
236228 ; RV64IF-NEXT: bnez a0, .LBB7_2
237229 ; RV64IF-NEXT: # %bb.1:
238230 ; RV64IF-NEXT: fmv.s ft0, ft1