1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=amdgcn-- -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX9-SAFE %s
; RUN: llc -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -mtriple=amdgcn-- -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX9-NNAN %s
; RUN: llc -mtriple=amdgcn-- -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=VI-SAFE %s
; RUN: llc -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -mtriple=amdgcn-- -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=VI-NNAN %s
; RUN: llc -mtriple=amdgcn-- -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI-SAFE %s
; RUN: llc -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -mtriple=amdgcn-- -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=SI-NNAN %s
define half @test_fmax_legacy_ugt_f16(half %a, half %b) #0 {
; GFX9-SAFE-LABEL: test_fmax_legacy_ugt_f16:
; GFX9-SAFE: ; %bb.0:
; GFX9-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v1
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
; GFX9-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; GFX9-NNAN-LABEL: test_fmax_legacy_ugt_f16:
; GFX9-NNAN: ; %bb.0:
; GFX9-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NNAN-NEXT: v_max_f16_e32 v0, v0, v1
; GFX9-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; VI-SAFE-LABEL: test_fmax_legacy_ugt_f16:
; VI-SAFE: ; %bb.0:
; VI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v1
; VI-SAFE-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
; VI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; VI-NNAN-LABEL: test_fmax_legacy_ugt_f16:
; VI-NNAN: ; %bb.0:
; VI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NNAN-NEXT: v_max_f16_e32 v0, v0, v1
; VI-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; SI-SAFE-LABEL: test_fmax_legacy_ugt_f16:
; SI-SAFE: ; %bb.0:
; SI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v0, v1, v0
; SI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; SI-NNAN-LABEL: test_fmax_legacy_ugt_f16:
; SI-NNAN: ; %bb.0:
; SI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-NNAN-NEXT: v_max_f32_e32 v0, v0, v1
; SI-NNAN-NEXT: s_setpc_b64 s[30:31]
%cmp = fcmp ugt half %a, %b
%val = select i1 %cmp, half %a, half %b
ret half %val
}
define <2 x half> @test_fmax_legacy_ugt_v2f16(<2 x half> %a, <2 x half> %b) #0 {
; GFX9-SAFE-LABEL: test_fmax_legacy_ugt_v2f16:
; GFX9-SAFE: ; %bb.0:
; GFX9-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v2, 16, v1
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v3, 16, v0
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v3, v2
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v2, v2, v3, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v1
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
; GFX9-SAFE-NEXT: v_and_b32_e32 v0, 0xffff, v0
; GFX9-SAFE-NEXT: v_lshl_or_b32 v0, v2, 16, v0
; GFX9-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; GFX9-NNAN-LABEL: test_fmax_legacy_ugt_v2f16:
; GFX9-NNAN: ; %bb.0:
; GFX9-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NNAN-NEXT: v_pk_max_f16 v0, v0, v1
; GFX9-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; VI-SAFE-LABEL: test_fmax_legacy_ugt_v2f16:
; VI-SAFE: ; %bb.0:
; VI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v2, 16, v1
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v3, 16, v0
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v3, v2
; VI-SAFE-NEXT: v_cndmask_b32_e32 v2, v2, v3, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v1
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v2, 16, v2
; VI-SAFE-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
; VI-SAFE-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; VI-NNAN-LABEL: test_fmax_legacy_ugt_v2f16:
; VI-NNAN: ; %bb.0:
; VI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NNAN-NEXT: v_max_f16_sdwa v2, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v0, v0, v1
; VI-NNAN-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; SI-SAFE-LABEL: test_fmax_legacy_ugt_v2f16:
; SI-SAFE: ; %bb.0:
; SI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v0, v2, v0
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v1, v3, v1
; SI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; SI-NNAN-LABEL: test_fmax_legacy_ugt_v2f16:
; SI-NNAN: ; %bb.0:
; SI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-NNAN-NEXT: v_max_f32_e32 v0, v0, v2
; SI-NNAN-NEXT: v_max_f32_e32 v1, v1, v3
; SI-NNAN-NEXT: s_setpc_b64 s[30:31]
%cmp = fcmp ugt <2 x half> %a, %b
%val = select <2 x i1> %cmp, <2 x half> %a, <2 x half> %b
ret <2 x half> %val
}
define <3 x half> @test_fmax_legacy_ugt_v3f16(<3 x half> %a, <3 x half> %b) #0 {
; GFX9-SAFE-LABEL: test_fmax_legacy_ugt_v3f16:
; GFX9-SAFE: ; %bb.0:
; GFX9-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v4, 16, v2
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v5, 16, v0
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v5, v4
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v3
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v2
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
; GFX9-SAFE-NEXT: v_and_b32_e32 v0, 0xffff, v0
; GFX9-SAFE-NEXT: v_lshl_or_b32 v0, v4, 16, v0
; GFX9-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; GFX9-NNAN-LABEL: test_fmax_legacy_ugt_v3f16:
; GFX9-NNAN: ; %bb.0:
; GFX9-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NNAN-NEXT: v_pk_max_f16 v1, v1, v3
; GFX9-NNAN-NEXT: v_pk_max_f16 v0, v0, v2
; GFX9-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; VI-SAFE-LABEL: test_fmax_legacy_ugt_v3f16:
; VI-SAFE: ; %bb.0:
; VI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v4, 16, v2
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v5, 16, v0
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v5, v4
; VI-SAFE-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v3
; VI-SAFE-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v2
; VI-SAFE-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v2, 16, v4
; VI-SAFE-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; VI-NNAN-LABEL: test_fmax_legacy_ugt_v3f16:
; VI-NNAN: ; %bb.0:
; VI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NNAN-NEXT: v_max_f16_sdwa v4, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v0, v0, v2
; VI-NNAN-NEXT: v_max_f16_e32 v1, v1, v3
; VI-NNAN-NEXT: v_or_b32_sdwa v0, v0, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; SI-SAFE-LABEL: test_fmax_legacy_ugt_v3f16:
; SI-SAFE: ; %bb.0:
; SI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v0, v3, v0
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v1, v4, v1
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v2, v5, v2
; SI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; SI-NNAN-LABEL: test_fmax_legacy_ugt_v3f16:
; SI-NNAN: ; %bb.0:
; SI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-NNAN-NEXT: v_max_f32_e32 v0, v0, v3
; SI-NNAN-NEXT: v_max_f32_e32 v1, v1, v4
; SI-NNAN-NEXT: v_max_f32_e32 v2, v2, v5
; SI-NNAN-NEXT: s_setpc_b64 s[30:31]
%cmp = fcmp ugt <3 x half> %a, %b
%val = select <3 x i1> %cmp, <3 x half> %a, <3 x half> %b
ret <3 x half> %val
}
define <4 x half> @test_fmax_legacy_ugt_v4f16(<4 x half> %a, <4 x half> %b) #0 {
; GFX9-SAFE-LABEL: test_fmax_legacy_ugt_v4f16:
; GFX9-SAFE: ; %bb.0:
; GFX9-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v6, 16, v3
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v7, 16, v1
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v7, v6
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v4, 16, v2
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v5, 16, v0
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v6, v6, v7, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v5, v4
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v3
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v2
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
; GFX9-SAFE-NEXT: v_mov_b32_e32 v2, 0xffff
; GFX9-SAFE-NEXT: v_and_b32_e32 v0, v2, v0
; GFX9-SAFE-NEXT: v_and_b32_e32 v1, v2, v1
; GFX9-SAFE-NEXT: v_lshl_or_b32 v0, v4, 16, v0
; GFX9-SAFE-NEXT: v_lshl_or_b32 v1, v6, 16, v1
; GFX9-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; GFX9-NNAN-LABEL: test_fmax_legacy_ugt_v4f16:
; GFX9-NNAN: ; %bb.0:
; GFX9-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NNAN-NEXT: v_pk_max_f16 v0, v0, v2
; GFX9-NNAN-NEXT: v_pk_max_f16 v1, v1, v3
; GFX9-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; VI-SAFE-LABEL: test_fmax_legacy_ugt_v4f16:
; VI-SAFE: ; %bb.0:
; VI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v6, 16, v3
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v7, 16, v1
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v7, v6
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v4, 16, v2
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v5, 16, v0
; VI-SAFE-NEXT: v_cndmask_b32_e32 v6, v6, v7, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v5, v4
; VI-SAFE-NEXT: v_cndmask_b32_e32 v4, v4, v5, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v3
; VI-SAFE-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v2
; VI-SAFE-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v2, 16, v4
; VI-SAFE-NEXT: v_or_b32_sdwa v0, v0, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v2, 16, v6
; VI-SAFE-NEXT: v_or_b32_sdwa v1, v1, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; VI-NNAN-LABEL: test_fmax_legacy_ugt_v4f16:
; VI-NNAN: ; %bb.0:
; VI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NNAN-NEXT: v_max_f16_sdwa v4, v1, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v1, v1, v3
; VI-NNAN-NEXT: v_max_f16_sdwa v5, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v0, v0, v2
; VI-NNAN-NEXT: v_or_b32_sdwa v0, v0, v5 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: v_or_b32_sdwa v1, v1, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; SI-SAFE-LABEL: test_fmax_legacy_ugt_v4f16:
; SI-SAFE: ; %bb.0:
; SI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v7, v7
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v6, v6
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v7, v7
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v6, v6
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v0, v4, v0
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v1, v5, v1
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v2, v6, v2
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v3, v7, v3
; SI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; SI-NNAN-LABEL: test_fmax_legacy_ugt_v4f16:
; SI-NNAN: ; %bb.0:
; SI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v7, v7
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v6, v6
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v7, v7
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v6, v6
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-NNAN-NEXT: v_max_f32_e32 v0, v0, v4
; SI-NNAN-NEXT: v_max_f32_e32 v1, v1, v5
; SI-NNAN-NEXT: v_max_f32_e32 v2, v2, v6
; SI-NNAN-NEXT: v_max_f32_e32 v3, v3, v7
; SI-NNAN-NEXT: s_setpc_b64 s[30:31]
%cmp = fcmp ugt <4 x half> %a, %b
%val = select <4 x i1> %cmp, <4 x half> %a, <4 x half> %b
ret <4 x half> %val
}
define <8 x half> @test_fmax_legacy_ugt_v8f16(<8 x half> %a, <8 x half> %b) #0 {
; GFX9-SAFE-LABEL: test_fmax_legacy_ugt_v8f16:
; GFX9-SAFE: ; %bb.0:
; GFX9-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v14, 16, v7
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v15, 16, v3
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v15, v14
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v12, 16, v6
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v13, 16, v2
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v14, v14, v15, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v13, v12
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v10, 16, v5
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v11, 16, v1
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v12, v12, v13, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v11, v10
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v8, 16, v4
; GFX9-SAFE-NEXT: v_lshrrev_b32_e32 v9, 16, v0
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v10, v10, v11, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v9, v8
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v8, v8, v9, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v3, v7
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v3, v7, v3, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v2, v6
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v2, v6, v2, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v5
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
; GFX9-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v4
; GFX9-SAFE-NEXT: v_cndmask_b32_e32 v0, v4, v0, vcc
; GFX9-SAFE-NEXT: v_mov_b32_e32 v4, 0xffff
; GFX9-SAFE-NEXT: v_and_b32_e32 v0, v4, v0
; GFX9-SAFE-NEXT: v_and_b32_e32 v1, v4, v1
; GFX9-SAFE-NEXT: v_and_b32_e32 v2, v4, v2
; GFX9-SAFE-NEXT: v_and_b32_e32 v3, v4, v3
; GFX9-SAFE-NEXT: v_lshl_or_b32 v0, v8, 16, v0
; GFX9-SAFE-NEXT: v_lshl_or_b32 v1, v10, 16, v1
; GFX9-SAFE-NEXT: v_lshl_or_b32 v2, v12, 16, v2
; GFX9-SAFE-NEXT: v_lshl_or_b32 v3, v14, 16, v3
; GFX9-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; GFX9-NNAN-LABEL: test_fmax_legacy_ugt_v8f16:
; GFX9-NNAN: ; %bb.0:
; GFX9-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NNAN-NEXT: v_pk_max_f16 v0, v0, v4
; GFX9-NNAN-NEXT: v_pk_max_f16 v1, v1, v5
; GFX9-NNAN-NEXT: v_pk_max_f16 v2, v2, v6
; GFX9-NNAN-NEXT: v_pk_max_f16 v3, v3, v7
; GFX9-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; VI-SAFE-LABEL: test_fmax_legacy_ugt_v8f16:
; VI-SAFE: ; %bb.0:
; VI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v14, 16, v7
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v15, 16, v3
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v15, v14
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v12, 16, v6
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v13, 16, v2
; VI-SAFE-NEXT: v_cndmask_b32_e32 v14, v14, v15, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v13, v12
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v10, 16, v5
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v11, 16, v1
; VI-SAFE-NEXT: v_cndmask_b32_e32 v12, v12, v13, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v11, v10
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v8, 16, v4
; VI-SAFE-NEXT: v_lshrrev_b32_e32 v9, 16, v0
; VI-SAFE-NEXT: v_cndmask_b32_e32 v10, v10, v11, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v9, v8
; VI-SAFE-NEXT: v_cndmask_b32_e32 v8, v8, v9, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v3, v7
; VI-SAFE-NEXT: v_cndmask_b32_e32 v3, v7, v3, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v2, v6
; VI-SAFE-NEXT: v_cndmask_b32_e32 v2, v6, v2, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v1, v5
; VI-SAFE-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
; VI-SAFE-NEXT: v_cmp_nle_f16_e32 vcc, v0, v4
; VI-SAFE-NEXT: v_cndmask_b32_e32 v0, v4, v0, vcc
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v4, 16, v8
; VI-SAFE-NEXT: v_or_b32_sdwa v0, v0, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v4, 16, v10
; VI-SAFE-NEXT: v_or_b32_sdwa v1, v1, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v4, 16, v12
; VI-SAFE-NEXT: v_or_b32_sdwa v2, v2, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: v_lshlrev_b32_e32 v4, 16, v14
; VI-SAFE-NEXT: v_or_b32_sdwa v3, v3, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; VI-NNAN-LABEL: test_fmax_legacy_ugt_v8f16:
; VI-NNAN: ; %bb.0:
; VI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; VI-NNAN-NEXT: v_max_f16_sdwa v8, v3, v7 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v3, v3, v7
; VI-NNAN-NEXT: v_max_f16_sdwa v9, v2, v6 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v2, v2, v6
; VI-NNAN-NEXT: v_max_f16_sdwa v10, v1, v5 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v1, v1, v5
; VI-NNAN-NEXT: v_max_f16_sdwa v11, v0, v4 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
; VI-NNAN-NEXT: v_max_f16_e32 v0, v0, v4
; VI-NNAN-NEXT: v_or_b32_sdwa v0, v0, v11 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: v_or_b32_sdwa v1, v1, v10 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: v_or_b32_sdwa v2, v2, v9 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: v_or_b32_sdwa v3, v3, v8 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_0 src1_sel:DWORD
; VI-NNAN-NEXT: s_setpc_b64 s[30:31]
;
; SI-SAFE-LABEL: test_fmax_legacy_ugt_v8f16:
; SI-SAFE: ; %bb.0:
; SI-SAFE-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v7, v7
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v15, v15
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v6, v6
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v14, v14
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v13, v13
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v12, v12
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v11, v11
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v10, v10
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v9, v9
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f16_f32_e32 v8, v8
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v7, v7
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v15, v15
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v6, v6
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v14, v14
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v13, v13
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v12, v12
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v11, v11
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v10, v10
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v9, v9
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-SAFE-NEXT: v_cvt_f32_f16_e32 v8, v8
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v0, v8, v0
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v1, v9, v1
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v2, v10, v2
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v3, v11, v3
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v4, v12, v4
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v5, v13, v5
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v6, v14, v6
; SI-SAFE-NEXT: v_max_legacy_f32_e32 v7, v15, v7
; SI-SAFE-NEXT: s_setpc_b64 s[30:31]
;
; SI-NNAN-LABEL: test_fmax_legacy_ugt_v8f16:
; SI-NNAN: ; %bb.0:
; SI-NNAN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v15, v15
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v7, v7
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v14, v14
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v6, v6
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v13, v13
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v12, v12
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v11, v11
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v10, v10
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v9, v9
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v8, v8
; SI-NNAN-NEXT: v_cvt_f16_f32_e32 v0, v0
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v15, v15
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v7, v7
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v14, v14
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v6, v6
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v13, v13
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v5, v5
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v12, v12
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v4, v4
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v11, v11
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v3, v3
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v10, v10
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v2, v2
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v9, v9
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v1, v1
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v8, v8
; SI-NNAN-NEXT: v_cvt_f32_f16_e32 v0, v0
; SI-NNAN-NEXT: v_max_f32_e32 v0, v0, v8
; SI-NNAN-NEXT: v_max_f32_e32 v1, v1, v9
; SI-NNAN-NEXT: v_max_f32_e32 v2, v2, v10
; SI-NNAN-NEXT: v_max_f32_e32 v3, v3, v11
; SI-NNAN-NEXT: v_max_f32_e32 v4, v4, v12
; SI-NNAN-NEXT: v_max_f32_e32 v5, v5, v13
; SI-NNAN-NEXT: v_max_f32_e32 v6, v6, v14
; SI-NNAN-NEXT: v_max_f32_e32 v7, v7, v15
; SI-NNAN-NEXT: s_setpc_b64 s[30:31]
%cmp = fcmp ugt <8 x half> %a, %b
%val = select <8 x i1> %cmp, <8 x half> %a, <8 x half> %b
ret <8 x half> %val
}
attributes #0 = { nounwind }
|